I have a form that excepts a file upload in ASP.NET. I need to increase the max upload size to above the 4 MB default.
I have found in certain places referencing the below code at msdn.
[ConfigurationPropertyAttribute("maxRequestLength", DefaultValue = )]
None of the references actually describe how to use it, and I have tried several things with no success. I only want to modify this attribute for certain pages that are asking for file upload.
Is this the correct route to take? And how do I use this?
I've the same problem in a win 2008 IIS server, I've solved the problem adding this configuration in the web.config:
The requestLengthDiskThreshold by default is 80000 bytes so it's too small for my application. requestLengthDiskThreshold is measured in bytes and maxRequestLength is expressed in Kbytes.
The problem is present if the application is using a
System.Web.UI.HtmlControls.HtmlInputFile
server component. Increasing the requestLengthDiskThreshold is necessary to solve it.For IIS 7+, as well as adding the httpRuntime maxRequestLength setting you also need to add:
Or in IIS (7):
Max file size can be restricted to a single MVC Controller or even to an Action.
web.config <location> tag can be used for this:
Or you can add these entries in area's own web.config.
This setting goes in your web.config file. It affects the entire application, though... I don't think you can set it per page.
"xxx" is in KB. The default is 4096 (= 4 MB).
I know it is an old question.
So this is what you have to do:
In you web.config file, add this in :
and this under
You see in the comment how this works. In one you need to have the sie in bytes and in the other one in kilobytes. Hope that helps.
You can write that block of code in your application web.config file.
By writing that code you can upload a larger file than now