SORU
20 Mart 2009, Cuma


Alıcı "en büyük istek uzunluğu aşıldı"

Upload fonksiyonu yazımı ve sorunları "Sistem.alıcı değilim Web.HttpException: en büyük istek uzunluğu aşıldı" dosyaları httpRuntimebelirtilen maksimum boyutundan daha büyük olan bir web.config (max boyutu 5120 set). Dosya için <input> basit bir kullanıyorum.

Sorun istisna Yükle düğmesini tıklayın-olay, özel durum kodu çalıştırmadan önce gerçekleşmeden önce atılmış olmasıdır. Nasıl ve catch yapmalıyım?

DÜZENLEME:Bu durum yavaş bağlantılar nedeniyle zaman aşımı bir sorun değil eminim öyle hemen atılmaz.

CEVAP
20 Mart 2009, Cuma


Böyle bir durum ne yazık ki yakalamak için kolay bir yolu yoktur. Ben ne sayfa düzeyinde veya genel olarak Application_Error en OnError yöntemi geçersiz olduğunu da.asax, sonra başarısızlık İsteği ve eğer bir hata transfer Max bir sayfa olduğunu kontrol edin.

protected override void OnError(EventArgs e) .....


private void Application_Error(object sender, EventArgs e)
{
    if (GlobalHelper.IsMaxRequestExceededException(this.Server.GetLastError()))
    {
        this.Server.ClearError();
        this.Server.Transfer("~/error/UploadTooLarge.aspx");
    }
}

Hack ama benim için çalışıyor aşağıdaki kodu bir

const int TimedOutExceptionCode = -2147467259;
public static bool IsMaxRequestExceededException(Exception e)
{
    // unhandled errors = caught at global.ascx level
    // http exception = caught at page level

    Exception main;
    var unhandled = e as HttpUnhandledException;

    if (unhandled != null && unhandled.ErrorCode == TimedOutExceptionCode)
    {
        main = unhandled.InnerException;
    }
    else
    {
        main = e;
    }


    var http = main as HttpException;

    if (http != null && http.ErrorCode == TimedOutExceptionCode)
    {
        // hack: no real method of identifying if the error is max request exceeded as 
        // it is treated as a timeout exception
        if (http.StackTrace.Contains("GetEntireRawContent"))
        {
            // MAX REQUEST HAS BEEN EXCEEDED
            return true;
        }
    }

    return false;
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • fouseyTUBE

    fouseyTUBE

    21 Mart 2011
  • FrankJavCee

    FrankJavCee

    29 Kasım 2008
  • SuppressedStorm

    SuppressedSt

    11 AĞUSTOS 2013