Kannan M
Kannan M

Reputation: 580

Host ASP.NET Core MVC app with multiple pathbase in IIS

Is it possible to host an ASP.NET Core MVC web app with different paths?

For example: I've an ASP.NET Core MVC web app hosted in IIS, with binding test.com.

Is it possible to cover multiple paths (app1, app2) without having to create multiple application under test.com.

https://test.com/app1/home
https://test.com/app2/home

Upvotes: 0

Views: 770

Answers (1)

Kannan M
Kannan M

Reputation: 580

This was achieved using UsePathBase (instead of creating multiple applications under IIS)

In StartUp.cs, added the below code to achieve it. WebsitePaths is a list of string ("app1", "app2").

foreach (var path in WebsitePaths)
{
   app.UsePathBase(new PathString($"/{path}"));
}

Note: I have the same user group who can access multiple site under multiple paths (app1,app2 - to display different contents) under a single domain (test.com).

Upvotes: 1

Related Questions