【问题标题】:HTTP Error 404.0 - Not Found AngularJS with IISHTTP 错误 404.0 - 使用 IIS 未找到 AngularJS
【发布时间】:2017-07-28 17:44:24
【问题描述】:

我使用 gulp 构建了我的客户端 angularJS 应用程序。在我部署到 IIS 后,我遇到了一个问题。通过菜单导航时,我的页面工作正常。但是当我按页面刷新(或)复制并粘贴 URL 时,它给了我 404 错误。 HTTP 错误 404.0 - 未找到 谁能帮我解决这个问题?

【问题讨论】:

    标签: angularjs iis gulp


    【解决方案1】:

    使用otherwise方法,这是其他人都没有匹配到时的默认路由


    您是否在路由配置部分配置了otherwise 选项?

    像下面这样?

    app.config(function($routeProvider) {
       $routeProvider.otherwise({
                 templateUrl : "main.htm",
                 controller : "mainController"
            });
    });
    

    你可以在这个链接下测试一下

    https://www.w3schools.com/angular/tryit.asp?filename=try_ng_routing_otherwise

    希望你能通过下面的讨论解决你的问题

    Refreshing page gives "Page not found"

    【讨论】:

    • 我通过菜单导航没有任何问题,这意味着我有一条路线。我也配置了其他路线。
    • @Velkumar 你试过$locationProvider.html5Mode(false); 吗?在您的路线配置中
    • 是的,现在它工作正常。谢谢 但是您知道如何从 URL 中删除 # 吗?
    猜你喜欢
    • 1970-01-01
    • 2011-08-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多