Use Visual Studio launch profiles to control ASP.NET Core debug URLs and environments
Control ASP.NET Core debug URLs and environments in Visual Studio using launchSettings.json profiles without changing application code.
22 Sept 2025, 13:20 UTC

Start here
If pressing F5 opens the wrong URL, or your ASP.NET Core app behaves as though it is running in Production on your development machine, you do not need to change application code. Visual Studio launch profiles in Properties/launchSettings.json let you set the launch URL, listening addresses, environment variables, and command-line arguments for a debug session. The setting applies only while you are debugging and is never deployed with the app.
How Visual Studio uses launchSettings.json
Visual Studio reads launchSettings.json when the project loads. Each profile under profiles appears in the debug toolbar dropdown next to the Start button. When you select a profile and press F5, Visual Studio passes that profile’s applicationUrl, launchUrl, environment variables, and arguments to the launcher—IIS Express or Kestrel, depending on the commandName—for that session only.
commandName tells Visual Studio what to launch:
Project: launches the ASP.NET Core project through Kestrel or IIS Express.Executable: launches an external executable you specify; requires a validexecutablePath.
Worked configuration
Open Properties/launchSettings.json in Solution Explorer. A typical ASP.NET Core project contains profiles similar to this:
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:51234",
"sslPort": 44321
}
},
"profiles": {
"HttpDevelopment": {
"commandName": "Project",
"launchUrl": "swagger/index.html",
"applicationUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"HttpsDevelopment": {
"commandName": "Project",
"launchUrl": "swagger/index.html",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Save the file, then restart the debugger. Open the debug toolbar dropdown and confirm both profiles appear. Select HttpsDevelopment and press F5. Expected result: the browser opens https://localhost:5001/swagger/index.html, and code that reads ASPNETCORE_ENVIRONMENT returns Development.
To inspect the file from a terminal, open a command prompt in the project directory—the folder containing the project file—and run:
cat Properties/launchSettings.json
On Windows PowerShell, use Get-Content Properties/launchSettings.json. Required permission is read access to the project folder. The command prints the file contents; it does not change state. If the file is missing, Visual Studio will not list custom profiles, and the app falls back to default launch behavior.
Limits and what this file does not do
- Development only.
launchSettings.jsonis Visual Studio tooling. It is not packaged with the published application and is ignored by IIS, Nginx, Azure App Service, and other production hosts. - Profile names must be unique. Duplicate names within the same file can cause Visual Studio to ignore or misidentify a profile.
- One session at a time. Switching profiles requires stopping the current debug session. The dropdown applies to the next launch only.
- No production secrets. Do not store connection strings, API keys, or passwords here. Machine-specific URLs can also leak internal addresses if committed.
Common mistakes
- Editing while debugging. Changes take effect only after you stop debugging and start a new session. Save the file, stop the app, then press F5 again.
- Committing local URLs. Review
.gitignoreand repository history before committing. Many teams excludelaunchSettings.jsonor commit a template without machine-specific ports. - Invalid executable path. If you use
commandName: "Executable", an incorrect or missingexecutablePathcauses the launch to fail with a debugger error rather than starting the app. - Expecting production behavior. A local
ASPNETCORE_ENVIRONMENTvalue does not configure production hosting. Set production environments through the host’s environment variables or app settings, not this file.
Check the result
- Open
Properties/launchSettings.jsonand confirm the profile names match the Visual Studio debug toolbar dropdown. - Select a profile, press F5, and confirm the browser opens the configured
launchUrl. - Add a temporary endpoint or log line that reports
ASPNETCORE_ENVIRONMENTto confirm the environment variable reached the app. - Confirm
launchSettings.jsoncontains no secrets and is handled according to your team’s version-control policy.
If you need to undo an edit, close the file without saving or restore it from version control. Because editing this file only changes a local development setting, no deployment rollback is required.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.