Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# AngularJS路由在站点托管到IIS后不工作,添加了额外的标签_C#_Asp.net_Angularjs_Asp.net Mvc_Angular Routing - Fatal编程技术网

C# AngularJS路由在站点托管到IIS后不工作,添加了额外的标签

C# AngularJS路由在站点托管到IIS后不工作,添加了额外的标签,c#,asp.net,angularjs,asp.net-mvc,angular-routing,C#,Asp.net,Angularjs,Asp.net Mvc,Angular Routing,我刚刚开始学习angularjs,通过构建一些小项目SPA+.NETMVC项目。 当我在IIS上运行我的应用程序时,一切正常,但当我在IIS上托管我的应用程序时,我遇到了路由问题 IISExpress URL:localhost/#/contact 预期url(IIS10):localhost/myappname/#/联系方式 实际URL(IIS10):localhost/myappname/#/#联系方式 如您所见,有一个额外的“#”,当我删除它时,我得到了正确的模板(联系人) app.js

我刚刚开始学习angularjs,通过构建一些小项目SPA+.NETMVC项目。 当我在IIS上运行我的应用程序时,一切正常,但当我在IIS上托管我的应用程序时,我遇到了路由问题

IISExpress URL:localhost/#/contact

预期url(IIS10):localhost/myappname/#/联系方式

实际URL(IIS10):localhost/myappname/#/#联系方式

如您所见,有一个额外的“#”,当我删除它时,我得到了正确的模板(联系人)

app.js

(function () {
    'use strict';

    angular.module('app', []);
    var scotchApp = angular.module('scotchApp', ['ngRoute']);

    scotchApp.config(function ($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'pages/home.html',
                controller: 'mainController'
            })

            .when('/about', {
                templateUrl: 'pages/about.html',
                controller: 'aboutController'
            })

            .when('/contact', {
                templateUrl: 'pages/contact.html',
                controller: 'contactController'
            });
    });
})();
(function () {
    angular
        .module('scotchApp')
            .controller('mainController', function ($scope) {
                $scope.message = 'Everyone come and see how good I look!';
            });

    angular
        .module('scotchApp')
        .controller('aboutController', function ($scope) {
            $scope.message = 'Look! I am an about page.';
        });

    angular
        .module('scotchApp')
        .controller('contactController', function ($scope) {
            $scope.message = 'Contact us! JK. This is just a demo.';
        });
})();
main.js

(function () {
    'use strict';

    angular.module('app', []);
    var scotchApp = angular.module('scotchApp', ['ngRoute']);

    scotchApp.config(function ($routeProvider) {
        $routeProvider
            .when('/', {
                templateUrl: 'pages/home.html',
                controller: 'mainController'
            })

            .when('/about', {
                templateUrl: 'pages/about.html',
                controller: 'aboutController'
            })

            .when('/contact', {
                templateUrl: 'pages/contact.html',
                controller: 'contactController'
            });
    });
})();
(function () {
    angular
        .module('scotchApp')
            .controller('mainController', function ($scope) {
                $scope.message = 'Everyone come and see how good I look!';
            });

    angular
        .module('scotchApp')
        .controller('aboutController', function ($scope) {
            $scope.message = 'Look! I am an about page.';
        });

    angular
        .module('scotchApp')
        .controller('contactController', function ($scope) {
            $scope.message = 'Contact us! JK. This is just a demo.';
        });
})();
HTML

<div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                    <li><a href="#"><i class="fa fa-home"></i> Home</a></li>
                    <li><a href="#about"><i class="fa fa-shield"></i> About</a></li>
                    <li><a href="#contact"><i class="fa fa-comment"></i> Contact</a></li>
                </ul>
    <div ng-view></div>
     </div>

据我所知,当IISexpress的项目是一个根,没有问题,但对于IIS10它不是,这是不可能的,对我来说,使它作为一个根。 我尝试了这个论坛的解决方案:没有帮助。 谷歌:还没有变化

也许有人知道什么是问题? 有什么建议吗? Tnx家伙需要在html中添加

<ul class="nav navbar-nav">
   <li><a href="#/"><i class="fa fa-home"></i> Home</a></li>
   <li><a href="#/about"><i class="fa fa-shield"></i> About</a></li>
   <li><a href="#/contact"><i class="fa fa-comment"></i> Contact</a></li>
</ul>
<div ng-view>
</div> 

虽然正确,但他遇到的问题是链接地址中的
#
。您添加了适当的斜杠,但可能值得一提的是sachila ranawaka。它在IIS和IISexpress上都起作用:)问题是因为我在像
#/contact
这样的路由中没有
/