Unfortunately, you cannot get the host URL of your application, since this bit is controlled by IIS / WebListener, etc. and does not apply directly to the application.
Now, a good alternative is to provide each of your servers with the ASPNET_ENV environment variable ASPNET_ENV that you can separate your logic. Here are some examples of how to use it:
Startup.cs:
public class Startup { public void Configure(IApplicationBuilder app) {
Here is another example when ASPNET_ENV = Dev and we want to do class separation instead of method separation:
Startup.cs:
public class Startup { public void Configure(IApplicationBuilder app) {
StartupDev.cs
public class StartupDev // Note the "Dev" suffix { public void Configure(IApplicationBuilder app) {
Hope this helps.
source share