Deploying Angular 6 ASP.NET Core application Deploying Angular 6 ASP.NET Core application asp.net asp.net

Deploying Angular 6 ASP.NET Core application


You need to use this code for ASP.NET Core 2.0, not what you are using. My application is published using this approach.

        app.UseMvc(routes =>        { //Remove this if you don't need it            routes.MapRoute(                name: "default",                template: "{controller=Home}/{action=Index}/{id?}");            routes.MapSpaFallbackRoute(                name: "spa-fallback",              defaults: new { controller = "Home", action = "SPAIndex" }); // For SPA         });

You need to have a Action in your HomeController which returns a View.Code for View is

<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>


Just make this change, it should work for Prod IIS

 public void ConfigureServices(IServiceCollection services)    {        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);        // In production, the Angular files will be served from this directory        services.AddSpaStaticFiles(configuration =>        {            configuration.RootPath = "ClientApp/dist/client";        });    }


Visual Studio 2019 brings a project template for this, just select new project in first steps on start page, ASP.NET Core Web Application C#, enter a solution name, and select Angular project template. You may base your solution on ASP.NET Core running under .NET Core or .NET Framework.