Understanding Project Folders and Files in ASP.NET Core
๐ Introduction
Hey hey! ๐
You just created a new ASP.NET Core project and boom ๐ฅ โ a bunch of folders and files youโve never seen before. You’re like…
“Umm… what even is ‘Connected Services’? And where did my Controllers go?” ๐
Don’t worry, my friend. You’re in the right place. Today, weโll explore the real project structure of ASP.NET Core โ without MVC, in its cleanest and simplest form.
Letโs make sense of it together! ๐ฏ
๐ What You Are Going to Learn in This Lesson
โ๏ธ What the default project structure of ASP.NET Core looks like
โ๏ธ What each folder and file does
โ๏ธ Real-life code to show how it all connects
โ๏ธ A simple way to explore and experiment
โ๏ธ Clarity on how ASP.NET Core apps start and run
๐๏ธ Breaking Down the Project Structure of ASP.NET Core
So hereโs what youโll typically see in your new ASP.NET Core Web App (without MVC):
MyWebApp/
โ
โโโ Connected Services/
โโโ Dependencies/
โโโ Properties/
โโโ wwwroot/
โโโ Pages/
โโโ appsettings.json
โโโ Program.cs
Letโs go folder-by-folder, file-by-file. โจ
This is your new playground. Letโs make it feel like home.
๐ Connected Services
This section is where you can connect your app to external services โ like Azure, databases, APIs, etc.
Itโs like the โAdd a buddyโ zone. You bring in helpers here. ๐ค
Not always used at first, but super handy later.
๐ฆ Dependencies
This is where all your packages and NuGet libraries live.
Think of it as your appโs backpack ๐ โ it carries all the tools you install.
It includes:
.NET libraries
Third-party packages
Framework references
Nothing to edit here, just know whatโs inside. ๐
๐ Properties
Inside this, youโll find a file called launchSettings.json
.
This file controls how your app runs during development. Like which browser opens or what port to use.
"profiles": {
"MyWebApp": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://localhost:5001"
}
}
โ๏ธ Basically, itโs a comfy cushion for your app to launch the way you like.
๐ wwwroot
Hereโs your public folder. ๐ก
Everything in wwwroot
is accessible to the outside world.
Use it for:
- CSS
- JavaScript
- Images
- Static files
If you put a file here, users can access it directly in the browser.
Example: wwwroot/css/site.css
โ opens at /css/site.css
๐ Pages
Here comes the star of the show โ the Pages
folder. ๐
This is where your Razor Pages live.
Each .cshtml
file here is a self-contained page.
Pages/
โโโ Index.cshtml
โโโ Index.cshtml.cs
โโโ Error.cshtml
Example: Index.cshtml
(your homepage):
@page
<h1>Welcome to My Web App!</h1>
Code-behind file (Index.cshtml.cs
):
public class IndexModel : PageModel
{
public void OnGet()
{
// Runs on GET request
}
}
Itโs all in one place โ HTML + logic = easy life. ๐
And yep โ this is a key player in the project structure of ASP.NET Core.
โ๏ธ appsettings.json
Your appโs config file. Stores settings like logging, connection strings, and more.
{
"Logging": {
"LogLevel": {
"Default": "Information"
}
}
}
Tip: You can add environment-specific versions too like appsettings.Development.json
.
๐ Program.cs
This is where your app boots up. No Startup.cs
anymore (in .NET 6+). Everything starts here.
Hereโs how a simple one looks:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapRazorPages(); // Enables Razor Pages
app.Run();
๐ฅ One file. One purpose. It brings your app to life!
โจ Recap โ Project Structure of ASP.NET Core
So just to jog your memory:
Connected Services/
โ external buddiesDependencies/
โ packages and librariesProperties/
โ launch settingswwwroot/
โ static filesPages/
โ your UI with Razor Pagesappsettings.json
โ configuration storeProgram.cs
โ where everything starts
Understanding the project structure of ASP.NET Core will make building apps so much smoother. No more guessing. Just confidence. ๐ช
๐งช Try it Yourself!
Try this in your terminal or VS:
dotnet new webapp -n HelloWebApp
Then open it up and explore all the folders.
Click, peek, break stuff, laugh, fix it again. Thatโs learning. ๐
๐ง Feeling Confused?
Totally normal! Itโs like moving into a new house โ everythingโs unfamiliar at first.
But once you know where the fridge and coffee maker are, youโre good. โ๐
Need a refresher? Scroll up. Or message me anytime. ๐ฌ
ย
๐ Next What?
Alright, now youโve mastered the project structure of ASP.NET Core (๐ high five!).
So whatโs next?
๐ In the next chapter, weโre gonna dive into Building Web Applications using ASP.NET Core.
Yup, real stuff. Real apps. Real fun. ๐
Weโll make things work. Build pages. Add features. You’ll see your code come to life. Canโt wait to show you!