Articles in this section
Category / Section

How to set upload file size limit for an UploadBox?

1 min read


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.


    <httpRuntime targetFramework="4.5" maxRequestLength="307200"/>

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.


        <requestLimits maxAllowedContentLength="314572800" />

The value of maxAllowedContentLength should be given in Bytes.

Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment