M
Marty McDonald
In global.asax we handle the application error event by gathering
exception info & putting it into a cookie. Then asp.net automatically
directs the user to our error page, where we use the cookie to show
descriptive error info. Our error page also deletes the cookie like
this...
//Remove cookie from response buffer, so deletion is effective server-
side.
if (context.Response.Cookies[cookieName] != null)
{
context.Response.Cookies.Remove(cookieName);
}
//Send an expired cookie to the client, to force deletion client-side.
if (context.Request.Cookies[cookieName] != null)
{
HttpCookie expiredCookie = new HttpCookie(cookieName);
expiredCookie.Expires = DateTime.Now.AddDays(-1d);
context.Response.Cookies.Add(expiredCookie);
}
Yet when the user navigates back to the app start page, the error
cookie is still present, which causes our app problems (if the error
cookie is present, our app skips certain logic). This is the code
that gets executed after the cookies are supposedly deleted as the
user is navigating away from the error page and to the app start
page...
public void Application_AuthenticateRequest(Object s, EventArgs e)
{
HttpCookie cookie = Request.Cookies["DiagnosticMessage"];
if (cookie != null) <====== The cookie is present here.
{
return;
}
Why would the cookie still be present? Thanks
exception info & putting it into a cookie. Then asp.net automatically
directs the user to our error page, where we use the cookie to show
descriptive error info. Our error page also deletes the cookie like
this...
//Remove cookie from response buffer, so deletion is effective server-
side.
if (context.Response.Cookies[cookieName] != null)
{
context.Response.Cookies.Remove(cookieName);
}
//Send an expired cookie to the client, to force deletion client-side.
if (context.Request.Cookies[cookieName] != null)
{
HttpCookie expiredCookie = new HttpCookie(cookieName);
expiredCookie.Expires = DateTime.Now.AddDays(-1d);
context.Response.Cookies.Add(expiredCookie);
}
Yet when the user navigates back to the app start page, the error
cookie is still present, which causes our app problems (if the error
cookie is present, our app skips certain logic). This is the code
that gets executed after the cookies are supposedly deleted as the
user is navigating away from the error page and to the app start
page...
public void Application_AuthenticateRequest(Object s, EventArgs e)
{
HttpCookie cookie = Request.Cookies["DiagnosticMessage"];
if (cookie != null) <====== The cookie is present here.
{
return;
}
Why would the cookie still be present? Thanks