SORU
31 AĞUSTOS 2010, Salı


Sistem.Net.WebException http kodları

kolay bir yolu System.Net.WebException bir http kodu almak için var mı?

CEVAP
1 EYLÜL 2010, ÇARŞAMBA


Belki de böyle bir şey...

try
{
    // ...
}
catch (WebException ex)
{
    if (ex.Status == WebExceptionStatus.ProtocolError)
    {
        var response = ex.Response as HttpWebResponse;
        if (response != null)
        {
            Console.WriteLine("HTTP Status Code: "   (int)response.StatusCode);
        }
        else
        {
            // no http status code available
        }
    }
    else
    {
        // no http status code available
    }
}

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

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • After Effects Tutorials w/ Mikey

    After Effect

    24 HAZİRAN 2009
  • TWiT Netcast Network

    TWiT Netcast

    27 EKİM 2005
  • Vicious Computers

    Vicious Comp

    14 EKİM 2006