Understanding Default Folder Structure
Before we move forward let understand auto generated web API Project folder structure.
📁 Folder Structure (Auto-generated while creating .NET Web API App):
MyWebApi/
├── Controllers/
├── Properties/
├── appsettings.json
├── Program.cs
├── MyWebApi.csproj
🔍 What Each Folder/File Does:
📁 Controllers/
📁 Properties/
📄 appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
},
"AllowedHosts": "*"
}
📄 Program.cs
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers();
var app = builder.Build();
app.MapControllers();
app.Run();
📄 MyWebApi.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
</Project>
✅ Summary:
Each part plays a specific role in the app's behavior:
🔧 Dependencies
🪄 “The Brain of the Application”
Because they determine what your app knows and can do — everything from routing, database access to authentication comes from here.
Located in Solution Explorer → Dependencies (in Visual Studio) or managed via *.csproj file.
✅ What It Includes:
🧠 Purpose & Importance:
Recommended by LinkedIn
📦 Example from .csproj:
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
⚙️ appsettings.json
📋 “The Control Center”
The single source of truth for your app’s behavior. It configures how your app talks, logs, connects, and behaves across environments.
Located at the root of your project.
✅ What It’s For:
A centralized configuration file to store:
🧠 Why It’s Important:
📝 Example:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"Default": "Server=.;Database=MyDb;Trusted_Connection=True;"
},
"AllowedHosts": "*"
}
🔄 Load in Program.cs:
var config = builder.Configuration;
var connStr = config.GetConnectionString("Default");
🚀launchSettings.json
🧪 “The Local Launchpad”
Your dev-only turbo booster. It sets up how your app starts, which environment it mimics, and what URL it lives on while you test it.
Located in Properties/launchSettings.json
✅ What It Controls:
Defines how your app runs locally during development:
🧠 Why It’s Useful:
📝 Example:
{
"profiles": {
"MyWebApi": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
🧩 Summary Table: