How to set maxRequestLength and maxAllowedContentLength for a specific location in asp.net mvc, web.config file?

I have an ASP.Net MVC 4 application that is needed to load large files into specific actions. The route in question is "~ / UploadArea / UploadController / UploadAction", and the configuration I have installed looks like this:

<location path="~/UploadArea/UploadController/UploadAction"> <system.web> <!-- maxRequestLength is in kilobytes (KB) --> <httpRuntime maxRequestLength="100000" /> <!-- 100MB --> </system.web> <system.webServer> <security> <requestFiltering> <!-- maxAllowedContentLength is in bytes (B) --> <requestLimits maxAllowedContentLength="100000000"/> <!-- 100MB --> </requestFiltering> </security> </system.webServer> </location> 

If I do not use the location and do not use the configuration for the entire application, it just works fine, otherwise nothing happens, where is the problem setting node?

+4
source share
1 answer

change your path to only be a controller / action, leave ~ / like this, I believe, makes IIS look for a literal path to the file that matches. therefore, depending on your routing and what this page is called, you can:

 <location path="UploadController/UploadAction"> 

or if this is the default action and is requested as mysite / UploadController, try:

 <location path="UploadController"> 
-2
source

All Articles