Angular 路线如果不区分大小写,则始终需要斜杠

Angular Route Always need slash if it's case insensitive

这是我使用的解决方法:

 $urlMatcherFactory.caseInsensitive(true);
 $urlMatcherFactory.strictMode(true); // or off nothing is work 

 $urlRouterProvider.rule(function ($injector, $location) {
            var path = $location.path(), normalized = path;//.toLowerCase();
            template = path;

            if (path !== normalized) {
               $location.replace().path(normalized);
            }
           }
        });

我已经解决了这个问题,请帮忙。

最后,我通过修改脚本标记中 _Layout.cshtml 文件中 Angular bootstrap 之前的 URL 找到了解决此问题的方法,方法是将尾部斜杠添加到URL 如果请求的 URL 以根应用程序路由结尾(使用 baseSiteUrlPath 键)并且它工作正常。

   if (window.location.href.substr(-1) != '/' 
        && window.location.href.toLowerCase().endsWith(baseSiteUrlPath.toLowerCase().substr(0, baseSiteUrlPath.length - 1)))
        window.location.href += '/';