Angular Application无法在IIS上运行

时间:2019-04-25 10:48:29

标签: angular iis angular-ui-router production-environment

我正在尝试在IIS上发布我的应用程序,但是当我尝试刷新时会得到

错误

The Web server is configured to not list the contents of this directory..

应用程序路径

 E:\tutorial\Angular Login\front\clientapi

角度构建

ng build --prod --base-href=/eclipse/

构建应用程序后,我在 dist 文件夹

中得到以下输出

enter image description here

我复制 clientapi 文件夹并将其粘贴到 C:\ ecilpse 文件夹

enter image description here

然后在 IIS 上发布 enter image description here

之后,我将Web.config文件添加到 eclipse 文件夹

<configuration>

<system.webServer>

  <rewrite>

    <rules>

      <rule name="Angular Routes" stopProcessing="true">

        <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="/eclipse/" />

        <!--<action type="Rewrite" url="/" />-->

      </rule>

    </rules>

  </rewrite>

</system.webServer>

</configuration>

1 个答案:

答案 0 :(得分:0)

问题已通过以下步骤解决。

  1. dist\clientapi复制所有文件
  2. 粘贴到c:\eciplse
  3. 使用<action type="Rewrite" url="./index.html" />
  4. 更新Web.config文件