0

I have two web sites developed using Aspnet core 3.1 Razor Pages, hosted by kestrel. Example:

https://localhost:50001/*
https://localhost:50002/*

There is no problem when running in debug mode. However in production I would like to do the old IIS method where we can add a virtual directory to the URL. Example:

https://example.com/MyAppA/*
https://example.com/MyAppB/*

I knew kestrel cannot do this, but I can't use IIS as well because I need to deploy these web site in non windows environment.

May I know if it is possible for me to modify the routing in Razor Pages to add the MyAppA or MyAppB in my code?

The simplest way of doing so is to move all the pages in [solution]\Pages\* to [solution]\Pages\MyAppA\*, but I will keep this as an last option.

Thanks

s k
  • 4,342
  • 3
  • 42
  • 61
  • Are those websites in different ASP.NET projets? If so, you might need a reverse proxy to handle the requests before forwarded them to the services. – ESG Aug 10 '20 at 13:19

2 Answers2

1

How about using the PathBase middleware, please try the answer here https://stackoverflow.com/a/57494684/4076996

zhimin
  • 2,740
  • 12
  • 22
0

You can try this,

public void ConfigureServices(IServiceCollection services)
{
      services.AddRazorPages(options =>
      {
           //this is page level so you need to add every page
           options.Conventions.AddPageRoute("/index", "MyAppA");
           options.Conventions.AddPageRoute("/test1", "MyAppA/test1");
      });
}
Vivek Bani
  • 3,703
  • 1
  • 9
  • 18
  • This is only change the default root directory to MyAppA (means MyAppA must exist prior to this setting), but not appending the MyAppA into the URL – s k Aug 11 '20 at 01:19