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

  • magnum33563

    magnum33563

    8 NİSAN 2011
  • Mega64

    Mega64

    24 ŞUBAT 2006
  • UberFacts

    UberFacts

    26 EKİM 2013