Is there any way by which i can get HTTP Response code out of Exception.
Actually i need to take few action based on Http Code 403 (Server busy).
Thanks for any kind of help.

What type of http client are you using? The exception contains a response where you can pull the HTTP status code from:

using System;
using System.IO;
using System.Net;
using System.Windows.Forms;

namespace daniweb
{
  public partial class frmHTTP2 : Form
  {
    public frmHTTP2()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      const string url = @"http://www.daniweb.com/broken/link.aspx";
      HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
      req.Method = "GET";
      req.Referer = string.Empty;
      try
      {
        HttpWebResponse objResponse = (HttpWebResponse)req.GetResponse();
        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
        {
          string htmlStuff = sr.ReadToEnd();
          sr.Close();
        }
      }
      catch (WebException ex)
      {
        HttpWebResponse resp = (ex.Response as HttpWebResponse);
        if (resp != null)
        {
          string msg = string.Format("Error: {0:F0} - {1}", (int)resp.StatusCode, resp.StatusCode.ToString());
          Console.WriteLine(msg);
          MessageBox.Show(msg);
          //System.Diagnostics.Debugger.Break();
        }
      }
    }
  }
}

Results in:

Error: 404 - NotFound
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.