加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – IE9从URL中删除#part(适用于Firefox!)

发布时间:2020-12-16 09:41:19 所属栏目:asp.Net 来源:网络整理
导读:我正在使用ASP.NET MVC路由AngularJS路由的应用程序. 我的网址看起来像: https://example.com/Request/#/Search/Request/123 当我分解时(http://example.com/Request)由ASP.NET MVC路由处理.即(Area = Request,controller =“Default”,action =“Index”)
我正在使用ASP.NET MVC路由AngularJS路由的应用程序.

我的网址看起来像:

https://example.com/Request/#/Search/Request/123

当我分解时(http://example.com/Request)由ASP.NET MVC路由处理.即(Area = Request,controller =“Default”,action =“Index”)

(#/ Search / Request / 123)由AngularJS路由处理.

当我在http://localhost:8080/时,这非常有效

问题是我将此应用程序部署到https://example.com/

在这种情况下,如果用户点击上面的链接(通过电子邮件收到),IE 9仅识别(https://example.com/Request/“)并且服务器永远不会获得(#/ Search / Request / 123).

我们在Web服务器上实现了企业SSO. SSO客户端拦截http请求,并在身份验证后使用URL重定向回请求的页面.

如果#fragie未作为http请求URL的一部分发送,则sso无法重定向回同一页面.

我认为这是一个常见的场景/问题.我会不断改变URL方案作为最后的手段.例如(# 至 !).

怎么解决这个?

解决方法

片段(#后面的URL部分)不一定由浏览器发送到服务器端.它们仅用于客户端使用(导航到文档中的特定位置,JavaScript支持).

RFC 2396第4.1节:

When a URI reference is used to perform a retrieval action on the
identified resource,the optional fragment identifier,separated from
the URI by a crosshatch (“#”) character,consists of additional
reference information to be interpreted by the user agent after the
retrieval action has been successfully completed
. As such,it is not
part of a URI,but is often used in conjunction with a URI.

(重点补充)

因此,除非您将#更改为其他字符,否则您提供的URL方案将无法可靠地运行.或者,你可以use JavaScript to transfer the information from the fragment in an input that will be reliably passed back to the server.但请注意,解决方案只有在浏览器中启用JavaScript时才有效,因此它(也)不是100%可靠的解决方案,可以与所有客户端一起使用.

无论哪种方式,使用不带片段的URL是一种更可靠的方法,如果您期望服务器解释该部分,则IMO是更好的设计选择.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读