Last post Feb 18, 2011 09:18 AM by .netchris
Feb 04, 2011 08:42 AM|.netchris|LINK
I have a HttpModule that should write a cookie to a user inside of the error event. However nothing ever seems to cause the client to actually receive a cookie:
**Edit:** With further inspection it appears that ASP.NET (or IIS I don't know which) will purge the cookies from a HttpResponse if error status is not removed with `server.ClearError()`. Is there a way to override this behavior without calling ClearError?
asp .net 4.0
Feb 07, 2011 10:41 AM|.netchris|LINK
bump, definitely requires clarification from Microsoft since I can't find this behavior documented anywhere
Feb 16, 2011 05:22 AM|niravbhattsai|LINK
How do you handle the error after you have added the cookie.
You should execute some error page manually to give the response.
You add cookie with Response.Cookies.Add, now when your server raises an error it discard all previous objects and just raise default error page or your cusom one. And hence your cookie will not passed to client with response.
Try with this raise your error event in module redirect to a page and add cookie in that page.
Feb 18, 2011 09:18 AM|.netchris|LINK
Apparently some part of the ASP.NET pipeline decide to send the response headers before it invokes the HttpModule error event making it impossible to serve cookies from there.