我有一个页面,我正在阅读查询字符串。如果查询字符串中存在某个值,我正在注册一个启动脚本。脚本执行后,我想从查询字符串中删除元素并使用新的 url 重新加载页面。
这是在页面预渲染事件中运行的代码。
for (int i = 0; i < 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);
}
}
但是重定向是在显示警报之前发生的。如何显示警报,然后在关闭警报后我可以重定向页面?