На сервере стоит
<httpRuntime executionTimeout="90" maxRequestLength="2048"/>
с клиента загружается файл ( размер > 2048 кб)
В данном случае нужно перехватить exception и отправить клиенту сообщение о превышении размера.
protected void Application_Error()
{
HttpException h = Server.GetLastError() as HttpException;
if (h != null && h.WebEventCode == WebEventCodes.RuntimeErrorPostTooLarge)
{
try
{
Server.ClearError();
Response.Write(h.Message);
}
catch
{
}
}
}
В данном случае клиенту приходит Abort. Замена
Response.Write
на
Response.Redirect(url, false)
тоже возвращает abort.
Попытка перехвата до
error'a
private void GlobalBeginRequest(object sender, EventArgs e)
{
var runTime = (HttpRuntimeSection)WebConfigurationManager.GetSection("system.web/httpRuntime");
var maxRequestLength = runTime.MaxRequestLength * 1024;
if (Request.ContentLength > maxRequestLength)
{
try{
Response.Redirect(url, false);
}
catch{
}
}
}
Также выдает Abort
В чем причина? Как сделать перехват
WebEventCodes.RuntimeErrorPostTooLarge
Это поведение только в ASP. Web DeveloperServer
При сборке под IIS перехват производится
вопрос решен