我很难弄清楚如何解决这个问题。我希望在服务器关闭时将错误捕获并将页面重定向到Maintenance.aspx
。但它在HttpContext.Current.Application["ErrorCode"].ToString();
收到错误。请帮我解决这个问题......
非常感谢。
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");
}
}
}