수 없습니다!
maxRequestLength
는 요청
와는 대응 asp.net 작업자에 의해 처리 한 서버를 친 후 일반 핸들러 또는 페이지가 실행되는 것을 의미 실제
HttpHandler
에
HttpWorkerRequest 이전 호출에 의해 처리된다. 당신은 귀하의 페이지 코드 또는 HttpHandler에서
maxRequestLength
을 제어 할 수 없습니다!
이
protected void Application_BeginRequest(object sender, EventArgs e)
{
IServiceProvider provider = (IServiceProvider)HttpContext.Current;
HttpWorkerRequest workerRequest = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
if (workerRequest.HasEntityBody())
{
long contentLength = long.Parse((workerRequest.GetKnownRequestHeader(HttpWorkerRequest.HeaderContentLength)));
}
}
당신은을 설정할 수 있습니다 : 당신이 할 수있는 코드의 요청 길이를 읽으려면
이 중 하나 HttpModule
또는 global.asax
파일을 통해,이 그것이 Global.asax에 내부에서 수행되는 방법이다 의 maxRequestLength
을 최대 값으로 설정하고 요청 길이가 원하는 값에 도달하면 코드에서 worker의 CloseConnection 메서드를 호출하십시오!
다음은 설정을 읽는 더 쉬운 방법입니다. http://stackoverflow.com/questions/4887016/how-to-access-httpruntime-section-of-web-config-from-codebehind –
@MikeSchall OP는 가능한 maxRequestLength를 변경하는 방법을 알려줍니다. 코드 스 니펫 위의 내용은 max-length가 아닌 모든 요청의 content-length를 읽는 방법입니다. –