최대 요청 길이를 초과했습니다.
내 사이트에 동영상을 업로드하려고 할 때 최대 요청 길이 초과 오류가 발생 합니다.
이 문제를 어떻게 해결합니까?
애플리케이션 호스팅에 IIS를 사용하는 경우 기본 업로드 파일 크기는 4MB입니다. 이를 늘리려면 web.config에서 아래 섹션을 사용하십시오.
<configuration>
<system.web>
<httpRuntime maxRequestLength="1048576" />
</system.web>
</configuration>
IIS7 이상에서는 아래 행도 추가해야합니다.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
참고 :
maxRequestLength
킬로바이트 단위로 측정됩니다.maxAllowedContentLength
바이트 단위 로 측정 됩니다.
이것이이 구성 예제에서 값이 다른 이유입니다. (둘 다 1GB에 해당)
여기에 언급되지 않았다고 생각하지만이 작업을 수행하려면 web.config에서이 두 값을 모두 제공해야했습니다.
에 system.web
<httpRuntime maxRequestLength="1048576" executionTimeout="3600" />
그리고 system.webServer
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
중요 : 두 값이 모두 일치해야합니다. 이 경우 최대 업로드는 1024MB입니다.
maxRequestLength에는 1048576 KILOBYTES 가 있고 maxAllowedContentLength에는 1073741824 BYTES가 있습니다.
분명한 건 알지만 간과하기 쉽습니다.
전체 사이트가 아닌 업로드에 사용될 것으로 예상되는 URL로 이러한 변경을 제한 할 수 있습니다.
<location path="Documents/Upload">
<system.web>
<!-- 50MB in kilobytes, default is 4096 or 4MB-->
<httpRuntime maxRequestLength="51200" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- 50MB in bytes, default is 30000000 or approx. 28.6102 Mb-->
<requestLimits maxAllowedContentLength="52428800" />
</requestFiltering>
</security>
</system.webServer>
</location>
그리고 누군가가이 예외를 처리하고 사용자에게 의미있는 설명을 표시 할 방법을 찾고있는 경우 (예 : "너무 큰 파일을 업로드하고 있습니다") :
//Global.asax
private void Application_Error(object sender, EventArgs e)
{
var ex = Server.GetLastError();
var httpException = ex as HttpException ?? ex.InnerException as HttpException;
if(httpException == null) return;
if(httpException.WebEventCode == WebEventCodes.RuntimeErrorPostTooLarge)
{
//handle the error
Response.Write("Too big a file, dude"); //for example
}
}
(ASP.NET 4 이상 필요)
최대 요청 크기는 기본적으로 4MB (4096KB)입니다.
여기에 설명되어 있습니다. https://support.microsoft.com/en-us/help/295626/prb-cannot-upload-large-files-when-you-use-the-htmlinputfile-server-co
위의 문서는이 문제를 해결하는 방법도 설명합니다. :)
There's an element in web.config to configure the max size of the uploaded file:
<httpRuntime
maxRequestLength="1048576"
/>
If you can't update configuration files but control the code that handles file uploads use HttpContext.Current.Request.GetBufferlessInputStream(true)
.
The true
value for disableMaxRequestLength
parameter tells the framework to ignore configured request limits.
For detailed description visit https://msdn.microsoft.com/en-us/library/hh195568(v=vs.110).aspx
maxRequestLength (length in KB) Here as ex. I took 1024 (1MB) maxAllowedContentLength (length in Bytes) should be same as your maxRequestLength (1048576 bytes = 1MB).
<system.web>
<httpRuntime maxRequestLength="1024" executionTimeout="3600" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576"/>
</requestFiltering>
</security>
</system.webServer>
To summarize all the answers in a single place:
<system.web>
<httpRuntime targetFramework="4.5.2" maxRequestLength="1048576"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
Rules:
- maxRequestLength (expressed in kb) value must match maxAllowedContentLength (expressed in bytes).
- most of the time your system.web section may already contains an "httpRuntime". set your targetFramework to the version of your .net used.
Notes:
- default value for maxRequestLength is 4096 (4mb). max value is 2,147,483,647
- default value for maxAllowedContentLength is 30,000,000 (around 30mb). max value is 4,294,967,295
more info MSDN
It bothered me for days too. I modified the Web.config file but it didn't work. It turned out that there are two Web.config file in my project, and I should modified the one in the ROOT directory, not the others. Hope this would be helpful.
If you have a request going to an application in the site, make sure you set maxRequestLength in the root web.config. The maxRequestLength in the applications's web.config appears to be ignored.
I was tripped up by the fact that our web.config file has multiple system.web sections: it worked when I added < httpRuntime maxRequestLength="1048576" /> to the system.web section that at the configuration level.
I had to edit the C:\Windows\System32\inetsrv\config\applicationHost.config
file and add <requestLimits maxAllowedContentLength="1073741824" />
to the end of the...
<configuration>
<system.webServer>
<security>
<requestFiltering>
section.
As per This Microsoft Support Article
I can add to config web uncompiled
<system.web>
<httpRuntime maxRequestLength="1024" executionTimeout="3600" />
<compilation debug="true"/>
</system.web>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1048576"/>
</requestFiltering>
</security>
참고URL : https://stackoverflow.com/questions/3853767/maximum-request-length-exceeded
'Nice programing' 카테고리의 다른 글
리플렉션을 사용하여 제네릭 메서드를 호출하는 방법은 무엇입니까? (0) | 2020.09.27 |
---|---|
LINQ에서 그룹화 (0) | 2020.09.27 |
Python이 해석되는 경우 .pyc 파일은 무엇입니까? (0) | 2020.09.27 |
Objective-C의 상수 (0) | 2020.09.27 |
치명적인 오류 : Python.h : 해당 파일 또는 디렉터리가 없습니다. (0) | 2020.09.27 |