【问题标题】:Angular 2+ app IIS hosted route does not work on reloadAngular 2+ 应用程序 IIS 托管路由在重新加载时不起作用
【发布时间】:2017-10-10 14:50:32
【问题描述】:

我在 IIS 8 上托管了 Angular 2+ 应用程序。所有路由都是客户端路由,除了一些以 /mutual-funds/* 开头的路由。对于那些路由,我想让 IIS 获取该文件夹并使用它的索引页面。我已经编写了重写规则,但它不适用于重新加载。任何帮助将不胜感激。

网络配置文件是:

 <rule name="AngularJS Routes" stopProcessing="false">
      <match url=".*" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/webapp/" />
    </rule>





     <rule name="Check1" stopProcessing="false">
      <match url="/mutual-funds/"/>
      <conditions logicalGrouping="MatchAll">
        <add input="{ REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="/webapp/mutual-funds/" />
    </rule>

【问题讨论】:

    标签: angular iis url-rewriting routing


    【解决方案1】:

    如果有人有回应,我会很感兴趣。

    作为一种解决方法,您可以使用哈希位置策略在您提供路由器的位置添加 { useHash: true }

    RouterModule.forRoot(routes, {useHash: true})
    

    它会在 URL 之后添加一个“#”。然后您可以使用 URL http://your-context/#mutual-funds 访问您的页面

    这里有一篇关于位置策略的好文章:https://codecraft.tv/courses/angular/routing/routing-strategies/

    【讨论】:

    • 我不想使用 HashLocationStratgey。
    猜你喜欢
    • 2016-12-22
    • 1970-01-01
    • 1970-01-01
    • 2018-01-15
    • 2017-03-25
    • 1970-01-01
    • 1970-01-01
    • 2016-10-13
    • 1970-01-01
    相关资源
    最近更新 更多