ASP.NET Core multiple angular app

前端 未结 3 1590
广开言路
广开言路 2021-02-04 13:42

I have an ASP.NET Core 2.1 and I need to setup workspace for multiple Angular applications with following routing:

http://someurl.com/main -> first app
http://someu

3条回答
  •  忘了有多久
    2021-02-04 14:31

    @sven.to's answer works, I am just pasting here the full snippet for clarity:

            app.Map("/foo", l => l.UseSpa(spa =>
            {
                // To learn more about options for serving an Angular SPA from ASP.NET Core,
                // see https://go.microsoft.com/fwlink/?linkid=864501
    
                spa.Options.SourcePath = "ClientApp";
    
                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            }));
    

    This adds the /foo prefix and now https://localhost:44383/foo/main.js will show you main.js while https://localhost:44383/main.js will give you 404 Not Found.

提交回复
热议问题