Reputation: 4863
for some unknown reason, I have '#!' added to my apps url when debugging in visual studio 2015.
urls look like this
http://localhost:58394/#!/customers
http://localhost:58394/#!/
I have searched all app if this is some sort of typo, but I cannot figure out where is this comming from.
I can see that in ASP.NET WEB API as well as in ASP.NET CORE WEB API...
For front end I'm using angular and angular-route 1.6.0
Any ideas where is this comming from?
I'm not using html5mode nor base tag and I'm happy for # to be there for now, I just don't understand why is the exclamation mark (!) in there ...
This app is not to be deployed on web and is not using any external service which could possibly use #! notation for any tracking or anything else.
The exclamation mark started to apear after the hast just recently so I guess this is caused by some the libs I'm using.
I just would like to know why '!'is there and what library it forcing this exclamation there.
Upvotes: 4
Views: 2035
Reputation: 4863
I have found this in angualr 1.6.0 changelog
$location: default hashPrefix to '!' (aa077e, #13812)
changelog: https://github.com/angular/angular.js/blob/master/CHANGELOG.md
change: https://github.com/angular/angular.js/commit/aa077e81129c740041438688dff2e8d20c3d7b52
BREAKING CHANGE
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 thanmydomain.com/#/a/b/c
will becomemydomain/#!/a/b/c
.
to revert to the old way just use
appModule.config(['$locationProvider', function($locationProvider) {
$locationProvider.hashPrefix('');
}]);
Upvotes: 5
Reputation: 7640
You should apply this in order to not to have hash bang for angular
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
<head>
<base href="/">
...
</head>
for angular 2, this is enough, I think:
<base href="/" />
Per your comment it seems some how you switch Hashbang Mode
Configuration:
$routeProvider
.when('/path', {
templateUrl: 'path.html',
});
$locationProvider
.html5Mode(false)
.hashPrefix('!');
Please see this
Upvotes: 1