The error affecting IIS 7 is probably not the same as IIS6. This bug has been fixed since 4.7, it has the following identifier: DevID 289778 .
Background
Here is a description of it: In IIS7, every time you leave the asp.net pipeline to return to the IIS pipeline, cookie headers are added if necessary. In integrated mode, you leave the asp.net pipeline between most events.
Therefore, when he writes down cookies as necessary, he checks to see if any cookies have been deleted. If not, it checks if cookies have been added. If so, he adds a header for this cookie. It also checks if any cookies have been changed. If so, he adds a headline for him. Although it iterates cookies, it records everything that has been changed.
If any cookies were deleted or any were changed, then it deletes all Set-Cookie headers and writes a new set. (Or at least he is trying. If the headers were reset, then obviously this is not possible.)
So far, so good. However, upon re-entering the managed pipeline, we read all the response headers back and restore the response cookies. This is necessary because some unmanaged modules may add new response cookies. However, it does not set the add flag for any cookies copied from response headers. So for now, all is well, right?
Bug
Well, not quite. Each time a cookie is added (or removed from) the Response.Cookies collection, the Request.Cookies collection Request.Cookies completely reloaded and then response cookies are added to it, setting the HttpCookie flag of the HttpCookie object HttpCookie . This is mistake. This causes the βAddedβ flag to be set for each response cookie each time each cookie is added or deleted.
This means that if you do not change or delete cookies, but add at least one cookie, all cookies previously added at other stages of the pipeline will be duplicated. However, if you change a cookie or delete a cookie from the Response.Cookies collection, then you will delete all duplicates that previously occurred.
Hackish Workaround
To work around this error, simply add and delete some arbitrary cookie or change the cookie during the same event that the headers are written. Usually it will be EndRequest , unless you use Server.Transfer , Server.Redirect , Response.Flush or Reponse.End (unless you set the endReponse parameter to false) anywhere in the application, in which case you should do this is the same event that is happening. Also, do not forget about any incidents in the libraries or about the Http modules you use. Essentially, you just want to add the following code for each individual event:
try{ var guid=Guid.NewGuid(); context.Response.Cookies.Add(new HttpCookie(guid.ToString(),string.Empty); context.Response.Cookies.Remove(guid.ToString()); } catch(HttpException) {