When you start in the world of ASP.NET, one of the first things you’ll encounter is that there are different types of projects you can choose from, depending on your needs.
In fact, it’s one of the most confusing things at the beginning because there is a huge number of them, and it’s easy to get lost among so many options.
So, let’s see the main projects in ASP.NET, their characteristics, and when it’s more appropriate to use each one.
Here is a summary of the different types of ASP.NET projects you will encounter.
| Command | Project Type | Description |
|---|---|---|
dotnet new web | Empty | Creates an empty project |
dotnet new webapi | ✅ RESTful API | Creates an API that follows the RESTful style for web services |
dotnet new mvc | ❌ MVC | Creates an application with the Model-View-Controller pattern |
dotnet new razor | ❌ Razor Pages | Creates a project with Razor Pages |
dotnet new blazorwasm | Blazor WebAssembly | Creates a client-side Blazor application with WebAssembly. |
dotnet new blazorserver | Blazor Server | Creates a Blazor Server application |
Not all of them are equally useful, nor used (not even remotely), and some of them are kept for compatibility. Currently, the ones you will use most frequently are:
- ✅ RESTful API: For almost everything
- Blazor: If you want to develop with this technology
- Empty Project: For a quick test (or to start from scratch)
But if you want more information about all of them, here it is so you can get to know them and know when it’s convenient to use them (or not) 👇
Creates an empty project without any default structure. This is useful if you want to create a completely customized application or if you need total control over the project configuration.
To create an empty project, simply run:
dotnet new web -n MiProyectoVacio
This will generate an empty project where you can add what you need: controllers, views, static files, services, among others.
Generates a RESTful API that follows HTTP conventions, using JSON as the data exchange format.
This type of project is common for exposing backend services, where a graphical interface is not necessary, but endpoints are provided that can be consumed by frontend or mobile applications.
To create an API project, use the following command:
dotnet new webapi -n MiApi
When to use it:
- Web services: If you are developing a backend that will be consumed by different clients.
- Microservices: If you are building a microservices architecture, each service can be a RESTful API.
- SPA applications: APIs + SPA frontends (React, Angular, Blazor).
Creates a project based on the Model-View-Controller (MVC) pattern. This pattern divides the application into three main components:
- Model (Model): Represents the data and business logic.
- View (View): Represents the graphical interface of the application.
- Controller (Controller): Acts as an intermediary between the model and the view.
To create a new MVC application, open the console and run the following command:
dotnet new mvc -n NombreDeMiAplicacion
When to use it:
- It has been the classic for years.
- Nowadays, it’s not used as much except in existing applications (legacy)
Razor Pages was released with .NET Core 2.0 (2017), promoted by Microsoft as a simpler alternative to MVC. Unlike MVC, a strict separation of controllers and views is not required.
However, it did not gain much popularity, except in internal projects, administrative forms, or environments where something very simple is sought without involving SPAs (React, Angular, Blazor).
To create a project with Razor Pages, run:
dotnet new razor -n MiRazorPageApp
When to use it:
- ⛔If you are threatened with a gun and you have no other choice… (and even then I would think about it)
Blazor is a web application development framework that allows you to create interactive applications using C# instead of JavaScript.
Blazor can run on the server (Blazor Server) or on the client (Blazor WebAssembly).
dotnet new blazorserver -n MiAplicacionBlazor
This command will create a new Blazor Server project with the basic folder and file structure needed.
When to use it:
- Interactive applications: If you are developing a web application that requires high user interactivity.
- SPA (Single Page Application): If you are building a single-page application (SPA) and prefer to use C# instead of JavaScript.
Common Use Cases
We have seen the types of projects that ASP.NET offers. These are the “real project types”. When we create a project we will have to choose a type and we cannot change it.
But we must not confuse the “project type” of ASP.NET with what we can do with this project (use cases)
We have already seen that the most powerful and versatile project type is RESTful API. But we can’t just make APIs with it.
So let’s see “use cases” that we can perform with ASP.NET, alone, or with other technologies 👇.
