You can store error data in the session and receive it on the user error page.
This code is in Global.asax :
protected void Application_Error(object sender, EventArgs e) { Exception err = Server.GetLastError(); Session.Add("LastError", err); } void Session_Start(object sender, EventArgs e) { Session["LastError"] = "";
Then on the error page page :
protected void Page_Load(object sender, EventArgs e) { Exception err = Session["LastError"] as Exception; //Exception err = Server.GetLastError(); if (err != null) { err = err.GetBaseException(); lblErrorMsg.Text = err.Message; lblSource.Text = err.Source; lblInnerEx.Text = (err.InnerException != null) ? err.InnerException.ToString() : ""; lblStackTrace.Text = err.StackTrace; Session["LastError"] = null; } }
source share