using System.Net;
public ActionResult Test()
{
try
{ }
catch (WebException ex)
{
HttpWebResponse res = (HttpWebResponse)ex.Response;
if (res.StatusCode == HttpStatusCode.OK) //200
{ }
else if (res.StatusCode == HttpStatusCode.BadRequest)//400
{ }
else if (res.StatusCode == HttpStatusCode.NotFound)//404
{ }
else if (res.StatusCode == HttpStatusCode.InternalServerError)//500
{ }
else
{ }
throw ex;
}
return View();
}