ASP.NET Core 3 Service…

ASP.NET Core 3 Service Registration – AddControllers() AddControllersWithViews() AddRazorPages()

With v3 and higher, there are several ways to register MVC. This way the application can only use what it requires, not the whole framework. This would result with a smaller size and being not sure, better performance.


If you are developing an API, go with this. This is only for API-related features, Views or pages are not supported.


This adds API + Views but not Pages. If you “dotnet new mvc”, it uses this code.


This adds support for Razor Pages and minimal controller support. If you “dotnet new web”, it uses this code.

These can be combined as well. The following is equivalent to calling AddMvc in ASP.NET Core 2.2:



#aspnetcore #dotnet #net-core

Deserialize json array with System.Text.Json

Json Data

    "FirstName": "Brick",
    "LastName": "Heck"
    "FirstName": "Sue Sue",
    "LastName": "Heck"

And the class and method for deserialization

     public class Dto {
	public string FirstName { get;	set;}
	public string LastName {	get;	set;}
// Deserializer method
public static IList < Dto > DeserializeSystemNotificationEmail(string json) {
	var options = new JsonSerializerOptions {
		AllowTrailingCommas = true,
		PropertyNameCaseInsensitive = true

	return JsonSerializer.Deserialize <IList<Dto>> (json, options);

A post about the performance of system.text.json

#json #System.Text.Json #net-core #dotnet

Configuration in .NET Core

#dotnet #net-core

.NET Core and .NET Standard

A nice article from MSDN Magazine:
.NET Standard – Demystifying .NET Core and .NET Standard
And a great video series about .NET Standard from the same author:


.NET Core Command Line CLI Basics

Yes, developing .NET apps without opening Visual Studio was something I wish for a long time. It was possible but wasn’t that simple. With .NET Core CLI, managing the project is simpler than ever. Let’s see how we can create a new project, build and run and learn some more commands.

1. Creating a Project/Solution & Adding Project to a Solution

After going to the folder you want to create the project. You can just type

 "dotnet new"

This will not work but you will see the options you can use.

For an MVC project, you can use

 "dotnet new mvc"

For a console app, use

 "dotnet new console"

If you want to create the project in a folder with a solution name you desire, use

 "dotnet new mvc -n MyNewMvcProject"

Once you do any of above, the files for the project will be created and you can jump start working on your projects. Details for the “dotnet new” command can be found here >>>

If you want to add projects under the solution, use “dotnet sln []” command. Click to see more details.

2. Running / Building the Projects

For running the project quickly, use

dotnet run

If you get an error of missing files, you have to restore the packages. Use

 dotnet restore 

This restores the dependencies and tools of a project that are specified in the project file. Note that “dotnet run” command, takes care of compiling and building the project as well. It runs “dotnew build” before it runs.

3. Adding Packages to the Projects & Adding Projects as Reference

You can use “dotnet add package PackageName” to add a package from NuGET. For example, to add Newtonsoft.Json, use

dotnet add package Newtonsoft.Json

You can specify the URL of the package as well:

dotnet add package Microsoft.AspNetCore.StaticFiles -s

The commands above must be the most used ones. For all, please visit the official article on microsoft >> .NET Core command-line interface (CLI) tools

#net-core #net-core-command-line-basics, #dotnet-core-cli-basics, #dotnet-new #dotnet