About the author
Why do I keep stumbling into more and more ASP.NET bugs?
Consider the following code. What it attempts to do is to expire all the cookies. Simple right? Notice that the loop runs only for as many cookies as there are present in the Request. However, it appeared that the following code actually causes an infinite loop to occur.
Can you figure out why?
for(int i=0;i<Request.Cookies.Count;i++){Response.Cookies[Request.Cookies[i].Name].Value = "";Response.Cookies[Request.Cookies[i].Name].Expires = DateTime.MinValue;}
In order to replicate the above situation, drop the above code into a Page's Load event. Make sure that you've actually allocated a cookie or two before running the code above.