<%@ Page Language="C#" %>
<script runat="server">
protected HttpException ex = null;
protected void Page_Load(object sender, EventArgs e)
{
ex = (HttpException)Server.GetLastError();
string safeMsg = String.Empty;
// Filter for Error Codes and set text
if (ex.ErrorCode >= 400 && ex.ErrorCode < 500)
{
ex = new HttpException
(ex.ErrorCode,
"Your file could not be found or " +
"there was an access problem.", ex);
}
else if (ex.ErrorCode > 499)
ex = new HttpException
(ex.ErrorCode,
"There was an error on the server.", ex);
else
ex = new HttpException
(ex.ErrorCode,
"There was a problem " +
"with the web site.", ex);
// Log the exception and notify system operators
ExceptionUtility.LogException(ex, "HttpErrorPage");
ExceptionUtility.NotifySystemOps(ex);
// Fill the page fields
exMessage.Text = ex.Message;
exTrace.Text = ex.StackTrace;
// Show Inner Exception fields for local access
if (ex.InnerException != null)
{
innerTrace.Text = ex.InnerException.StackTrace;
InnerErrorPanel.Visible = Request.IsLocal;
innerMessage.Text = ex.InnerException.Message;
}
// Show Trace for local access
exTrace.Visible = Request.IsLocal;
// Clear the error from the server
Server.ClearError();
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Generic Error Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2>Http Error Page</h2>
<asp:Panel ID="InnerErrorPanel" runat="server" Visible="false">
<asp:Label ID="innerMessage" runat="server"
Font-Bold="true" Font-Size="Large" /><br />
<pre>
<asp:Label ID="innerTrace" runat="server" />
</pre>
</asp:Panel>
Error Message:<br />
<asp:Label ID="exMessage" runat="server"
Font-Bold="true" Font-Size="Large" />
<pre>
<asp:Label ID="exTrace" runat="server" visible="false" />
</pre>
</div>
</form>
</body>
</html>