Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <customErrors mode="On" defaultRedirect="~/Error.aspx"></customErrors>
- <script RunAt="server">
- void Application_Error(object sender, EventArgs e)
- {
- Exception ex = Server.GetLastError();
- if (ex != null && Session != null)
- {
- ex.Data.Add("ErrorTime", DateTime.Now);
- ex.Data.Add("ErrorSession", Session.SessionID);
- HttpContext.Current.Cache["LastError"] = ex;
- }
- }
- </script>
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack) return;
- if (HttpContext.Current.Cache["LastError"] != null)
- {
- Exception ex = (Exception)HttpContext.Current.Cache["LastError"];
- if (ex.Data["ErrorTime"] != null && ex.Data["ErrorSession"] != null)
- if ((DateTime)ex.Data["ErrorTime"] > DateTime.Now.AddSeconds(-30d) && ex.Data["ErrorSession"].ToString() == Session.SessionID)
- Label1.Text = ex.InnerException.Message;
- }
- }
- Server.Transfer(String.Concat("~/Error.aspx?message=", HttpUtility.UrlEncode(ex.InnerException.Message)))
- void Application_Error(object sender, EventArgs e)
- {
- HttpContext.Current.Cache["LastError"] = Server.GetLastError().GetBaseException();
- Server.ClearError();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack) return;
- if (HttpContext.Current.Cache["LastError"] != null)
- {
- Exception ex = (Exception)HttpContext.Current.Cache["LastError"];
- if (ex != null)
- Label1.Text = ex.Message;
- }
- }
- Server.ClearError();
Add Comment
Please, Sign In to add comment