1

I have built an angular 6 application with .Net core 2.1 and deployed to azure server on IIS web server. The routing is working fine on localhost when refresh, but not working on azure server. I checked angular deployment guideline and added following code in web.config file

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

Now, I got into new problem. All the files now contains index.html content, instead of their respective file content. enter image description here enter image description here

What am I missing here? Do I need to make any changes to kestrel server

1
  • As I outlined in the answer, this rewrite is not necessary and doesn't work for ASP.NET Core. If your question is specific to ASP.NET Core's SPA Services / JavaScript Services, I suggest opening a question that includes your csproj and startup.cs Commented Sep 13, 2018 at 15:07

1 Answer 1

2

This section of the angular guide does not apply to ASP.NET Core hosted Angular applications. Only for non-.NET or classic ASP.NET websites, a rewrite module definition is needed.

If you started your application based on ASP.NET Core's templates for angular or SPAs, you have rewriting / SPA fallback routes set up already.

I suggest starting from applications created with dotnet new angular -o MyAngularApp our using VS' angular templates (both use the same template packages).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.