我很难理解为什么我的基本 href 似乎区分大小写。我有一个带有基本 href 的页面并使用 angularjs 路由。
html:
<html ng-app="app">
<head>
<base href="/Foo/"/>
</head>
<body>
<div>Foo</div>
<div ng-view></div>
</body>
</html>
js:
var module = angular.module('app', []);
module.config(function ($routeProvider, $locationProvider) {
$routeProvider
.when('/Home/Page1', { templateUrl = 'partials/page1' })
.otherwise({ redirectTo: '' });
$locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!');
});
如果我导航到http://www.example.com/Foo/,那很好。但是当我导航到http://www.example.com/foo/我得到一个角度错误:
Error: Invalid url "http://www.example.com/foo/", missing path prefix "/Foo" !
at Error (<anonymous>)
at Object.LocationUrl.$$parse (http://www.example.com/foo/Scripts/angular.js:4983:13)
at Object.LocationUrl (http://www.example.com/foo/Scripts/angular.js:5014:8)
at $LocationProvider.$get (http://www.example.com/foo/Scripts/angular.js:5387:21)
at Object.invoke (http://www.example.com/foo/Scripts/angular.js:2809:28)
at http://www.example.com/foo/Scripts/angular.js:2647:37
at getService (http://www.example.com/foo/Scripts/angular.js:2769:39)
at Object.invoke (http://www.example.com/foo/Scripts/angular.js:2787:13)
at $CompileProvider.directive (http://www.example.com/foo/Scripts/angular.js:3613:43)
at Array.forEach (native) angular.js:5582
如果它有帮助/有所作为,则站点托管在 IIS 上并使用 MVC 4。