简体   繁体   中英

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

I'm new to .net core and angular. I made a simple app and was looking for a decent guide on how to deploy it to IIS. I'm using .net core 2.2 and angular 7.

Most of what I could find is describing the deployment steps for pure angular applications. I tried to run dotnet publish on a solution and then point IIS to the output, but with no luck. I also tried to move the content of ClientApp\\dist folder to the wwwroot folder, but there was no positive effect.

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

Does anyone knows where to find a working step by step guide, or maybe could share their experience on how to make this work?

Thank's in advance!

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

In the web.config you set Angular routes:

<?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>

If you are deploying it in the sub folder not root. Then set the base href of your app in the index.html .

For example:

<base href="/myapp">

I think I solved this one a bit randomly.

I tried to use not CLI dotnet publish but VS2017 publish to folder function (which should be essentially the same in my world, but I'll check files tomorrow and update this comment if there was some differences).

Then I pointed an IIS to the target folder and added users IUSR, NETWORK, NETWORK SERVICE and IIS_IUSRS with full control permissions on Security tab.

And... that just worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM