RuntimeErrorPostTooLarge abort response
От: Black_Moon  
Дата: 05.06.12 20:41
Оценка:
На сервере стоит
<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
Re: RuntimeErrorPostTooLarge abort response
От: Black_Moon  
Дата: 06.06.12 06:52
Оценка:
Это поведение только в ASP. Web DeveloperServer
При сборке под IIS перехват производится

вопрос решен
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.