How to set upload file size limit for an UploadBox?
When you upload a file using an UploadBox, you can limit the upload file size, since uploading large files can be restricted by setting the file size limit.
Uploading a file can be restricted based on its size, by setting the maximum file size limit in the webconfig file. Create a website with UploadBox control and set the maxRequestLength key value for httpRuntime tag under system.web as follows.
<configuration> <system.web> <httpRuntime targetFramework="4.5" maxRequestLength="307200"/> </system.web> </configuration>
The value of maxRequestLength has to be given in Kilo Bytes (KB).
When the application is run directly from the developer environment, it is enough to have the maxRequestLength added in httpRuntime section of system.web. But while deploying it to the server, you must set the maxAllowedContentLength value under system.webserver tag in webconfig, so that file limit is applied on hosting the website in server.
<configuration> <system.webServer> <security> <requestFiltering> <requestLimits maxAllowedContentLength="314572800" /> </requestFiltering> </security> </system.webServer> </configuration>
The value of maxAllowedContentLength should be given in Bytes.