2011-12-02 16 views
4

我有處理文件上傳的ASP.NET IHttpHandler模​​塊。我在配置文件中將文件大小限制設置爲50MBmaxAllowedContentLength不適用於IHttpHandler IIS7

<system.webServer> 
    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="52428800" /> 
     </requestFiltering> 
    </security> 
    </system.webServer> 

但是上傳13mb文件時仍然出錯。

System.Web.HttpException (0x80004005): Maximum request length exceeded. 

如何增加默認允許的文件大小?

回答

1

使用以下位置的Web應用程序的web.config文件

<httpRuntime maxRequestLength="52428800" /> 
+3

這其實是不對的 - http://stackoverflow.com/a/3787284/ - 你需要在這裏千字節。 – sharptooth

+0

正確的maxRequestLength以KB爲單位,請參閱此處:http://msdn.microsoft.com/en-gb/library/e1f13641%28v=vs.85%29.aspx –

2

總之,提高文件上傳大小爲50 MIB在IIS7下面添加線在網絡中的正確位置config文件:

<system.webServer> 
    <security> 
     <requestFiltering> 
     <requestLimits maxAllowedContentLength="52428800" /> 
     </requestFiltering> 
    </security> 
    </system.webServer> 

<system.web> 
    <httpRuntime maxRequestLength="51200" /> 
    </system.web> 

1024 X 1024 X 50 = 5242880字節50 MIB

1024×50 = 51200昆明植物研究所在50 MIB

相關問題