Base solution for your next web application
Open Closed

Run Angular UI App and ASP.NET core API in IIS in one sub domain? #11581


User avatar
0
pliaspzero created

Hi, is it possible to run Angular UI App and ASP.NET core API in IIS in one sub domain? What needs to be done / cheked for that?


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Yes, this is possible. If you download a merged solution from aspnetzero.com website, it adds the below middleware into your Host applicaion. You need to place this right before static files middleware in your Startup.cs file.

    app.Use(
        async (context, next) =>
        {
            await next();
            if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
            {
                context.Request.Path = "/index.html";
                await next();
            }
        }
    );
    

    After doing this, you just need to copy your Angular app's publish output to wwwroot folder of your published Host app.