ASP.NET File Upload Progress - Knowledge Base

« Back to Knowledge Base list

Reject a file before uploading

Q:

Is there a way for the component to reject a file before it goes through the business of uploading the file? In other words, I don't want clients to watch a 50MB file appear as though it is uploading for 15 minutes, and then get a rejection notification AFTER waiting because the file might be 51MB when the limit is set to 50.

A:

Set the maximum size of HTTP request in Web .config:

  <!--

  maxRequestLength is in KB (50MB here)

  -->
  <httpRuntime

  maxRequestLength="50000"

  executionTimeout="300"

  />

Add the following line to application settings of Web .config:

<appSettings>

<add key="OboutInc.FileUpload.CancelOnServerException" value="True" />

</appSettings>
 
Add the property
OnClientServerException to FileUploadProgress control to see the server exception’s message.