Set launchurl for production environment in ASP.NET Core Web API

Viewed 1880

I have implemented Swagger in my Web API (ASP.NET Core 3.1) and my launch url is /swagger. I have edited my launchSettings.json in order of this, and it works good in my development machine, but not after publishing in production server.

I have read that launchSettings.json is only used on the local development machine, and if I want to use certain of these settings in the production machine I need to store such settings in the appsettings.json file.

But I couldn't find how to set this file. Some help would be appreciated, thanks in advance.

3 Answers

In the launchSettings.json the launch URL is the page that is opened when the application starts. Is this the setting you are looking for? (In my opinion in a production environment this is not a relevant setting.)

If I am correct in the production environment the /swagger URL doesn't load when you open it in a browser. The reason for this could be an "if (env.IsDevelopment) {...}" or something similar in the Startup class which conditionally adds the swagger middleware.

The settings that are present within this file are going to be used when we run the .NET core application either from Visual Studio or by using .NET Core CLI.

The most important point that you need to keep in mind is this launchSettings.json file is only used within the local development machine. That means this file is not required when we publishing our asp.net core application to the production server.

If you have certain settings and you want your application to use such settings when you publish and deploy your asp.net core application to the production server, then you need to store such settings in the appsettings.json file. Generally, in the ASP.NET Core application, the configuration settings are going to be stored in the appsettings.json file.

You can read this nice article about this topic : Article

Related