Get Angular2 routing working on IIS 7.5

前端 未结 6 969
情深已故
情深已故 2020-12-05 17:37

I have been learning Angular2. The routing works just fine when running on the nodejs lite-server. I can go to the main (localhost:3000) page and move through the applicatio

6条回答
  •  北海茫月
    2020-12-05 18:29

    If you use a Core 2.1 project, you can skip the web.config rewrite rules and accomplish Angular deep linking by putting this code at the bottom of your Startup.cs.

       app.Use(async (context, next) =>
       {
           context.Response.ContentType = "text/html";
           await context.Response.SendFileAsync(Path.Combine(env.WebRootPath, "index.html"));
       });
    

    Source

提交回复
热议问题