More details about maxRequestLength & maxAllowedContentLength in web.config

We have the below code in our web.config allowing the user to upload a max 30 MB file. I also see maxAllowedContentLength which is set at 100 MB.

 <location path="api/documentUpload">     <system.web>       <!-- Allow maximum 1024x30 = 30720 KB (30 MB) file size for document upload. -->       <httpRuntime maxRequestLength="30720" />     </system.web>     <system.webServer>       <security>         <requestFiltering>           <!-- Allow file size upto 1024x1024x100 = 104857600 bytes (100 MB)-->           <requestLimits maxAllowedContentLength="104857600" />         </requestFiltering>       </security>     </system.webServer>   </location> 

So when a user tries to upload say a 90 MB file, we check the request’s content length in the controller and return an error:

if (httpRequest != null && httpRequest.ContentLength > FileUploadConstants.MaxFileUploadSize) {     string errorMessage = "Cannot upload more than 30 MB."     return Content(HttpStatusCode.OK, errorMessage, new JsonMediaTypeFormatter(), "text/plain"); } 

My question here is, in the above scenario does the entire 90 MB gets transferred to server or does it get transferred when we actually try to access the file like HttpPostedFile httpPostedFile = httpRequest.Files[0];

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.