在IIS上托管SPA创建路由问题

时间:2015-08-24 06:10:05

标签: angularjs iis single-page-application

我在IIS上托管了我的AngularJS应用程序。

但在浏览网址时,它显示为http://localhost/MyApp#/login 它应该是http://localhost/MyApp/#/login

  1. 为什么会有区别?

  2. 如何解决这个问题?

  3. 同样,页面上的链接也显示错误的网址。

    <ul>
        <li><a href="/#/MyPage1">My Page 1</a></li>
        <li><a href="/#/MyPage2">My Page 2</a></li>
        <li><a href="/#/MyPage3">My Page 3</a></li>
    </ul>
    

    点击任意链接即可生成网址http://localhost/#/MyPage1,但该网址应为http://localhost/MyApp/#/MyPage1

    请建议解决方案。

1 个答案:

答案 0 :(得分:0)

使用<base url="" />代码,docs

<head>
<base href="http://localhost/MyApp/">
</head>