Response.Redirect - 如果当前页面的目标 URL 的 URL 带有哈希值,则发送带有哈希值的重定向时出现问题
我正在使用 ASP.NET Webforms C# 3.5 并利用 Response.Redirect 在事件调用后重定向页面。
如果我提交请求,第一个请求可以正常工作。我目前正在使用 Response.Redirect 。 我尝试使用 Server.Transfer 并将 True 和 False 作为第二个参数传递给 Redirect 函数,并尝试关闭 SmartNavigation。
如果我点击提交按钮,页面就会执行它应该做的事情,并且锚点会强制页面到正确的位置。如果我再次单击“提交”,则会返回相同的 URL,并且浏览器除了坐下来“挂起”之外不会执行任何操作。如果我从 URL 中删除散列部分,则重定向工作正常。
仅当请求使用锚点重定向到当前 URL 并且使用锚点(哈希符号)进行新的重定向时,似乎才会出现此问题
Response.Redirect(/Script.aspx?param1=something¶m2=something#anchor);
我也尝试过以下操作:
Response.Redirect(/Script.aspx?param1 =某事¶m2=某事&#anchor)
;
无论哪种情况,移除锚点都可以解决问题。
Chrome 和 Firefox 中都会出现此问题。 Firebug 报告请求完成并显示响应字符串,所有内容看起来都应该带有井号,但浏览器只是挂起。我所说的挂起是指将光标显示为进度\正在做某事光标类型。
I am using ASP.NET Webforms C# 3.5 and utilizing Response.Redirect to redirect the page after an event call.
If I submit a request the first request works fine. I am using Response.Redirect currently.
I have tried using Server.Transfer and passing True and False as the second parameter to the Redirect function as well as attempting to turn off SmartNavigation.
IF I click my submit button the page does what it's supposed to and the anchor forces the page to the correct location. If I then click submit again the same URL is returned and the browser doesn't do anything but sit and "hang." If I remove the hashed portion from my URL the redirect works fine.
The problem only seems to occur if the request was redirected to the current URL with an anchor and a new redirect occurs with the anchor (hash symbol)
Response.Redirect(/Script.aspx?param1=something¶m2=something#anchor);
I've also tried this:
Response.Redirect(/Script.aspx?param1=something¶m2=somethinganchor)
;
In either case removing the Anchor fixes the problem.
This problem occurs in Chrome and Firefox. Firebug reports the request completing and shows the response string and everything looks like it should with pound sign and all but the browser just hangs. By hang I mean shows the cursor as the progress\doing something cursor type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Response.Redirect 的常见问题。
您可以设置
或者可以将其作为附加查询字符串参数传递并使用 javascript 附加锚点:
This is a common problem with Response.Redirect.
You can either set
Or you can pass it as an additional query string parameter and use javascript to append the anchor: