How to execute Startup script before response.redirect?
<p>I have a page where I am reading the query string. if a certain value exists in querystring I am registering a start up script. after the script is executed, I want to remove the element from querystring and reload the page with the new url.</p>

<p>This is the code which runs in page pre-render event. </p>

<pre><code>for (int i = 0; i &lt; this.Page.Request.QueryString.Count; i++)
            {
                if (this.Page.Request.QueryString[i].Equals("filesize"))
                {
                    ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Maximum file size exceeded.');", true);

                    var nameValueCollection = HttpUtility.ParseQueryString(HttpContext.Current.Request.QueryString.ToString());
                    nameValueCollection.Remove("exception");
                    string url = HttpContext.Current.Request.Path + "?" + nameValueCollection;
                    Response.Redirect(url);
                }
            }
</code></pre>

<p>But the redirect is taking place before the alert is shown. How can I show the alert, then after closing the alert I can redirect the page?</p>
