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

asp.net – 为什么有#!在我的角度应用程序的网址中

发布时间:2020-12-16 06:50:38 所属栏目:asp.Net 来源:网络整理
导读:由于某种未知的原因,我有’#
由于某种未知的原因,我有’#!’在visual studio 2015中调试时添加到我的应用程序url.

网址看起来像这样

http://localhost:58394/#!/customers
http://localhost:58394/#!/

我已经搜索了所有应用程序,如果这是某种拼写错误,但我无法弄清楚这是从哪里来的.

我可以在ASP.NET WEB API以及ASP.NET CORE WEB API中看到…

对于前端我使用角度和角度路线1.6.0

这有什么想法来自哪里?

我没有使用html5mode也没有基本标签,我很高兴#现在在那里,我只是不明白为什么感叹号(!)在那里……

此应用程序不会在Web上部署,也不会使用任何可能使用#的外部服务!任何跟踪或其他任何内容的表示法.

最近的感叹号开始出现,所以我猜这是由我正在使用的一些库引起的.

我只是想知道为什么’!’就在那里,它在哪个图书馆里强迫这个惊叹号.

解决方法

我在angualr 1.6.0 changelog中找到了这个

$location: default hashPrefix to ‘!’ (aa077e,#13812)

更改日志:https://github.com/angular/angular.js/blob/master/CHANGELOG.md

变化:https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52

突然变化

The hash-prefix for $location hash-bang URLs has changed from the
empty string “” to the bang “!”. If your application does not use
HTML5 mode or is being run on browsers that do not support HTML5 mode,
and you have not specified your own hash-prefix then client side URLs
will now contain a “!” prefix. For example,rather than
mydomain.com/#/a/b/c will become mydomain/#!/a/b/c.

恢复旧的方式只是使用

appModule.config(['$locationProvider',function($locationProvider) {
    $locationProvider.hashPrefix('');
}]);

(编辑:李大同)

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

    推荐文章
      热点阅读