Recursive redirect on error handler page
<p>I use the following MSDN code on my master page to detect if the browser accepts cookies:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if(!this.IsPostBack) {
        if(Request.QueryString["CookieTest"] == null) {
            Response.Cookies["TestCookie"].Value = "Test";
            Response.Redirect("CookieCheck.aspx.redirect=" + Server.UrlEncode(Request.Url.ToString())));
        }
        else if((string)Request.QueryString["Test"] == "passed") {
            // my stuff...
        }
    }
}
</code></pre>

<p>The CookieCheck.aspx contains the following:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
    if(Request.Cookies["TestCookie"] == null)
        Response.Redirect(Request.QueryString["redirect"] + "?Test=notPassed", true);
     else
        Response.Redirect(Request.QueryString["redirect"] + "?Test=passed", true);
}
</code></pre>

<p>Within the web.config i have defined the following:</p>

<pre><code>&lt;customErrors mode="On" defaultRedirect="Error.aspx" /&gt;
</code></pre>

<p>Now the recognizing of the cookies works well, but I have this problem: Whenever an error occurs on the page and I should be redirected to Error.aspx (and this worked before the whole cookie detection thing), the redirection seems stuck in an infinite loop and appends more and more "?Test=passed" to the URL. I should mention that the Errors.aspx also has the same masterpage and thus also performs the cookie check. However I have no clue why the redirection doesn't stop. Is there a way to solve this problem other than to exlude the Errors.aspx page from having the master page? Thank you very much.</p>
