How to increase the max upload file size in ASP.NET?

后端 未结 15 3222
青春惊慌失措
青春惊慌失措 2020-11-22 06:09

I have a form that excepts a file upload in ASP.NET. I need to increase the max upload size to above the 4 MB default.

I have found in certain places referencing the

15条回答
  •  时光取名叫无心
    2020-11-22 06:11

    To increase uploading file's size limit we have two ways

    1. IIS6 or lower

    By default, in ASP.Net the maximum size of a file to be uploaded to the server is around 4MB. This value can be increased by modifying the maxRequestLength attribute in web.config.

    Remember : maxRequestLenght is in KB

    Example: if you want to restrict uploads to 15MB, set maxRequestLength to “15360” (15 x 1024).

    
        
        
    
    

    2. IIS7 or higher

    A slight different way used here to upload files.IIS7 has introduced request filtering module.Which executed before ASP.Net.Means the way pipeline works is that the IIS value(maxAllowedContentLength) checked first then ASP.NET value(maxRequestLength) is checked.The maxAllowedContentLength attribute defaults to 28.61 MB.This value can be increased by modifying both attribute in same web.config.

    Remember : maxAllowedContentLength is in bytes

    Example : if you want to restrict uploads to 15MB, set maxRequestLength to “15360” and maxAllowedContentLength to "15728640" (15 x 1024 x 1024).

    
        
        
    
    
                  
        
           
              
             
           
       
    
    

    MSDN Reference link : https://msdn.microsoft.com/en-us/library/e1f13641(VS.80).aspx

提交回复
热议问题