Translate

> > ASP.NET Custome Error Page

ASP.NET Custome Error Page

Posted on Friday, July 6, 2012 | No Comments

<system.web>
    <customErrors mode="On" defaultRedirect="UI/ErrorPage.aspx" redirectMode="ResponseRewrite"/>
</system.web>

protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                HttpContext ctx = HttpContext.Current;

                Exception exception = ctx.Server.GetLastError();

                string errorInfo =
                   "<br>Offending URL: " + ctx.Request.Url.ToString() +
                   "<br>Source: " + exception.Source +
                   "<br> <b> Message: " + exception.Message + "</b>" +
                   "<br>Stack trace: " + exception.StackTrace;
                lblMsg.Text = errorInfo;
            }
            catch (Exception ex)
            {
               
            }
        }

Leave a Reply

Powered by Blogger.