Base solution for your next web application
Open Closed

IIS - Is is possible to run Angular UI and ASP.NET CORE Backend under one Domain? #11638


User avatar
0
pliaspzero created

Hi,

how / is it possible in IIS to run Angular UI and ASP.NET CORE Backend under one Domain?


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

    Hi,

    Yes, it is possible. You can place output of the Angular app to the wwwroot folder of ASP.NET Core app. You also need to place middleware below to Startup.cs of your project to redirect all not found URLS to index.html of Angular app.

    You can place this middleware right after static file middleware.

    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();
            }
        }
    );