Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pick an Authentication Type in a new ASP.NET Core 7 project?

I would like to learn how to create an ASP.NET Core MVC 7 application that has Users.

When I create a new ASP.NET Core Web App, I am asked what type of Authentication type I would like to use:

Additional information screenshot

I've never done this before, so I really don't know. The little "info" circle isn't any help either.

The authentication method

I am just learning, so there is no need to pay for an Azure Cloud Database service. I have found some tutorials, but they all seem to be for older versions, like this one for MVC 3:

https://learn.microsoft.com/en-us/aspnet/mvc/overview/older-versions/mvc-music-store/mvc-music-store-part-7

Microsoft has an ASP.NET Core 7 tutorial here:

https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/start-mvc?view=aspnetcore-7.0&tabs=visual-studio

But, they opted to select None as the Authentication. It does say:

For more information, including alternative approaches to create the project, see Create a new project in Visual Studio.

But, the link to Create a new project in Visual Studio also uses None as the Authentication.

There are some answers here that talk about it:

How to get current user in asp.net core

But, nobody says where to start.

I'm new at this, so I really don't know where to start.

Ideally, I would like to store my Users in a Microsoft SQL database.


1 Answers

The four authentication type should like below:

No Authentication: This option will create an application with no authentication. You will have to implement your own authentication logic.

Individual User Accounts: This option will create an application with user authentication using ASP.NET Identity. It provides registration, login, and password reset features out of the box. Please notice: This will store all the user information inside the sql server by using the connection string.

Microsoft Identity Platform: This option will create an application that uses Azure Active Directory (Azure AD) for authentication. It is suitable for applications that require corporate authentication.

Windows Authentication: This option will create an application that uses Windows Authentication. It is suitable for intranet applications.

If you create the application by using the Individual User Accounts, you could modify the connection string inside the appsetting.json's connection string, then there is no need to modify other thing, asp.net core will intergate the identity to the application automatically.

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Core7Identity-53bc9b9d-9d6a-45d4-8429-2a2761773502;Trusted_Connection=True;MultipleActiveResultSets=true"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft.AspNetCore": "Warning"
    }
  },
  "AllowedHosts": "*"
}
like image 55
Brando Zhang Avatar answered Sep 14 '25 14:09

Brando Zhang