奇怪的#_=_出现在response.redirect ASP.NET之后的url末尾

发布于 2024-12-08 09:50:07 字数 213 浏览 0 评论 0原文

这里有人使用 Response.Redirect() 方法,您是否遇到过浏览器地址栏上 uri 末尾附加的一些奇怪字符?
奇怪的字符是哈希、下划线、等号和下划线(不含空格),如下所示...我不知道这些是什么意思,当这些奇怪的字符出现时,重定向并没有正确地发生。

 #_=_ 

对此有任何见解请分享。谢谢

Anyone here using Response.Redirect() method, do have you encountered some strange characters attached to the end of the uri on the browser address bar?
The strange characters are hash, underscore, equal sign and underscore (without spaces) such as below... I have no idea what are these all about and when these strange characters appear, the redirection didn't happen properly.

 #_=_ 

Any insights on this please share. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小傻瓜 2024-12-15 09:50:07

URL 的 location-part# 后面的任何内容均指页面中的锚点,通常是 < /code> 或 <无论 id="">。有些网站使用它们(可能与客户端 Javascript 一起)来执行魔法,但既然你问这个,我感觉你的情况并非如此。因此,没有真正的韵律或理由表明这些字符本身的存在或不存在会导致重定向是否有效。事实上,它们甚至不会在 HTTP 请求中发送到服务器(至少 Firefox 不会)。

您是否查看过发生这种情况时的 HTTP 请求交换?像 Live HTTP Headers、HttpFox 或 Firebug(查看 Net 面板)之类的东西将帮助您解决此问题,并且可能会向您指出错误的 #_=_ 的来源。

Anything in the location-part of a URL that follows a # refers to an anchor in the page, usually an <a name=""> or <whatever id="">. Some web sites use them (probably with client-side Javascript) to perform magic, but since you are asking this, I get the feeling that's not the case for you. So, there's no real rhyme or reason to that the existence or absence of those characters in and of themselves would cause the redirection to work or not. In fact, they aren't even sent to the server in the HTTP request (at least, Firefox doesn't).

Have you had a look at the HTTP request exchanges when this is happening? Something like Live HTTP Headers, HttpFox or Firebug (look at the Net panel) will help you with this, and might point you to where the errant #_=_ is coming from.

唐婉 2024-12-15 09:50:07

这是我基于其他几个人的解决方案:

$(function () {
    if (window.location.href.indexOf("#_=_") > -1) {
        //remove facebook oAuth response bogus hash
        if (window.history && window.history.pushState) {
            history.pushState('', document.title, window.location.pathname);
        } else {
            window.location.href = window.location.href.replace(location.hash, "");
        }
    }
});

https://stackoverflow.com/a/7845639/1467810

https://stackoverflow.com/a/15323220/1467810

https://stackoverflow.com/a/2295951/1467810

Here's my solution based on a couple others out there:

$(function () {
    if (window.location.href.indexOf("#_=_") > -1) {
        //remove facebook oAuth response bogus hash
        if (window.history && window.history.pushState) {
            history.pushState('', document.title, window.location.pathname);
        } else {
            window.location.href = window.location.href.replace(location.hash, "");
        }
    }
});

https://stackoverflow.com/a/7845639/1467810

https://stackoverflow.com/a/15323220/1467810

https://stackoverflow.com/a/2295951/1467810

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文