将 Angular 7 个使用 visual studio 2017 模板制作的应用程序部署到 IIS

Deploy Angular 7 app made with visual studio 2017 template to IIS

我是 .net 核心和 angular 的新手。我制作了一个简单的应用程序,正在寻找有关如何将其部署到 IIS 的不错的指南。我正在使用 .net core 2.2 和 angular 7.

我能找到的大部分内容都是描述纯 angular 应用程序的部署步骤。我尝试 运行 dotnet publish on a solution 然后将 IIS 指向输出,但没有成功。我也试过把ClientApp\dist文件夹的内容移动到wwwroot文件夹下,但是没有什么积极的效果。

我认为应该用 index.html 或 web.config 文件做一些事情。

有谁知道在哪里可以找到工作分步指南,或者可以分享他们如何使这项工作成功的经验?

提前致谢!

I believe there is something that should be done with index.html or web.config file.

web.config 你设置 Angular 路线:

<?xml version="1.0" encoding="utf-8"?>
<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="./index.html" />
      </rule>
    </rules>
  </rewrite>
</system.webServer>

</configuration>

如果您将其部署在非根目录的子文件夹中。然后在 index.html.

中设置您的应用程序的基本 href

例如:

<base href="/myapp">

我想我解决这个问题有点随意。

我尝试不使用 CLI dotnet publish,而是使用 VS2017 发布到文件夹功能(这在我的世界中应该基本相同,但我明天会检查文件,如果有一些差异,会更新此评论)。

然后我将一个 IIS 指向目标文件夹,并添加用户 IUSR、NETWORK、NETWORK SERVICE 和 IIS_IUSRS 在“安全”选项卡上具有完全控制权限。

而且...刚刚奏效。