I'm hardly to figure out how to solve this.. I want to catch the error when the server is turn off and redirect the page to Maintenance.aspx. But it's getting error at HttpContext.Current.Application["ErrorCode"].ToString();.Please help me how to solve this...
Many thanks.
try{
// method here
}
catch (Exception ex)
{
Panel1.Visible = true;
string statuscode = HttpContext.Current.Application["ErrorCode"].ToString(); //Getting error here!
if (statuscode != null || statuscode != string.Empty)
{
if (statuscode == "500")
{
lblDetailMsg.Text = "<b>Error Page- <b> " + HttpContext.Current.Application["ErrorPage"].ToString() + " <br /> <b>Error Message-</b> The Requested Page was not found.";
Response.Redirect("Maintenance.aspx");
}
}
}