|
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MyErrorHandler : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (HttpContext.Current.Application.Get("LastException") != null)
{
try
{
Exception ex = (Exception)HttpContext.Current.Application.Get("LastException");
string Code = (string)HttpContext.Current.Application.Get("ErrorCode");
uxErrorMessage.Text = ex.Message;
uxStackTrace.Text = ex.StackTrace;
uxErrorCode.Text = Code;
}
catch (Exception exc)
{
uxErrorMessage.Text = exc.Message;
uxStackTrace.Text = exc.StackTrace;
uxErrorCode.Text = "Unexpected Error";
}
}
else
{
uxErrorMessage.Text = "Does not contain any information about error!!!";
uxStackTrace.Text = "Not available!";
uxErrorCode.Text = "Not available!";
}
//HttpContext.Current.Application.Remove("LastException");
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Expertise area: ASP.NET, C#, Microsoft Office SharePoint 2010 & 2007, Web Service, Windows-based Applications etc.
Blog: http://mydevdiary.blogspot.com/