2012-10-11 1 views
2

나는 나의 web.config 파일이 추가 :파일 업로드 제한 크기는 어떻게 설정합니까? 그러나 의미있는 응답이 있습니까?

<httpRuntime maxRequestLength="40960"/> <!-- Limit to 40 megabytes --> 

을 내가 40메가바이트보다 큰 무언가를 업로드하려고 할 때, 나는 파이어 폭스에서 이것을 얻을 :

The connection was reset 

The connection to the server was reset while the page was loading. 

    * The site could be temporarily unavailable or too busy. Try again in a few 
    moments. 
    * If you are unable to load any pages, check your computer's network 
    connection. 
    * If your computer or network is protected by a firewall or proxy, make sure 
    that Firefox is permitted to access the Web. 

도 혜택을 누릴 수있는 방법이 있나요 이 파일 크기 제한이 내장되어 있지만 실제로는 좋은 오류 페이지가 표시됩니까? 물론 컨트롤러에서이 검사를 할 수는 있지만 거대한 파일이 내 서버에 도달했기 때문에 그 시점에서 트래픽이 이미 소비되었습니다.

if (image.ContentLength > 40960) // 'image' is HttpPostedFileBase 

의견이 있으십니까?

답변

3

global.asax.cs에서이 점은 어떻습니까?

void Application_Error(object sender, EventArgs e) 
{ 
    if (Request.TotalBytes > 40960 * 1024) 
    { 
     Server.ClearError(); 
     Response.Clear(); 
     Response.Write("File uploaded is greater than 40 MB"); 
    } 

} 
관련 문제