🚀 Introduction

When you create an ASP.NET Core project, one of the first files you will see in the Properties folder is launchSettings.json. This file plays an important role in defining how your application runs during development. In simple words, it contains the settings for running and debugging your app in Visual Studio, Visual Studio Code, or with the .NET CLI.

Think of it as a blueprint that tells your system how to start the project—which URL to use, which port to run on, and what environment (like Development, Staging, or Production) to load.

📝 What is LaunchSettings.json?

The launchSettings.json file is a JSON-based configuration file that:

For example, when you press F5 in Visual Studio, the IDE checks this file to know how to run your app.

⚙️ Structure of LaunchSettings.json

Here’s a simple example of what a launchSettings.json file looks like:

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:5000",
      "sslPort": 44301
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "MyApp": {
      "commandName": "Project",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}

🔑 Key Components of LaunchSettings.json

1️⃣ IIS Settings

👉 Example:

"iisSettings": {
  "iisExpress": {
    "applicationUrl": "http://localhost:5000",
    "sslPort": 44301
  }
}

2️⃣ Profiles

👉 Example:

"profiles": {
  "MyApp": {
    "commandName": "Project",
    "applicationUrl": "https://localhost:5001;http://localhost:5000",
    "environmentVariables": {
      "ASPNETCORE_ENVIRONMENT": "Development"
    }
  }
}

3️⃣ Environment Variables

👉 Example:

"environmentVariables": {
  "ASPNETCORE_ENVIRONMENT": "Development"
}

4️⃣ Application URL

👉 Example:

"applicationUrl": "https://localhost:5001;http://localhost:5000"

5️⃣ Launch Browser

👉 Example:

"launchBrowser": true

💡 How Does LaunchSettings.json Work?

👉 Example:
If ASPNETCORE_ENVIRONMENT is set to Development, then the app will load:

appsettings.Development.json

🎯 Why is LaunchSettings.json Important?

✅ Summary

The launchSettings.json file in ASP.NET Core is a configuration file that controls how your application runs during development. It defines profiles, URLs, ports, and environment variables. By using it, developers can easily switch between environments, control how their app starts, and ensure consistency across different team members’ setups. Understanding launchSettings.json is key to managing and debugging ASP.NET Core applications effectively.