Avoid downloading files larger than 10 MB

Is there any way (possibly a module) that can cause IIS7 to reject a message with a file larger than 10 MB?

My ASP.NET application has a download page, and the file cannot be larger than 10 MB, I believe that I can check the file size only after everything has already been sent to the server.

An IIS7 module would be the right choice for this, does anyone know one thing?

+4
source share
1 answer

You can set the limit in Web.Config

<system.web> <httpRuntime maxRequestLength="xxxxx" executionTimeout="xx"/> </system.web> 

sidenote:

IIS7 rejects any file larger than 30 megabytes by default, you can enlarge it by adding the following code

 <security> <requestFiltering> <requestLimits maxAllowedContentLength="XXXXXX″ /> </requestFiltering> </security> 

If you want to get the size of the content before downloading, you can use the HTTP HEAD method to get the Content-Length.

Implementation

+6
source

All Articles