Click here to Skip to main content
15,173,152 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to allow maximum request length for specific method instead of global setting in webconfig.

<httpruntime maxrequestlength="629145600" executiontimeout="2400" requestvalidationmode="2.0">

What I have tried:

public ActionResult savefile(file file)
Updated 13-Jan-21 23:44pm
Sandeep Mewara 14-Jan-21 2:39am
AFAIK, irrespective of method, you need to configure it in global settings and at IIS level to allow a defined length.

1 solution

Use the <location> tag in your config file:
<location path="YourController/SaveFile">
        <httpRuntime maxRequestLength="629145600" executionTimeout="2400" />
                <requestLimits maxAllowedContentLength="644245094400"  />
NB: maxRequestLength is in KB; maxAllowedContentLength is in bytes. You should normally specify both.

Use the location element in the Web.config file - Application configuration in ASP.NET - ASP.NET | Microsoft Docs[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900