I’m going to show you how you can easily create a .NET Core MVC application with login and logout functionality. This uses Identity Framework.
What is Identity Framework?
ASP.NET Core Identity is a membership system that adds login functionality to ASP.NET Core apps. Users can create an account with the login information stored in Identity or they can use an external login provider. Identity can be configured using a SQL Server database to store user names, passwords, and profile data.
Prerequisites:
- Visual Studio for Mac
- Terminal
- Docker Desktop for Mac
- Azure Data Studio
- Docker Desktop for Mac
The way that is offered in Visual Studio for Mac does not work.
Open visual studio
Go down to .NET Core > App
Select ASP.NET Core Web App
Select your target framework
Give your project and solution a name
Run the project and registration and login are missing
As you can see, this feature is not currently available in Visual Studio for Mac by default. You have to, therefore, create your project from the terminal.
How do I create this?
Open the terminal
$ dotnet new mvc -o DemoProject -uld --auth Individual
Download Docker and Azure Data Studio
Start Docker
Create a new container
docker run
-d --name
-e 'ACCEPT_EULA=Y'
-e 'SA_PASSWORD='
-e 'MSSQL_PID=Developer'
-p 1433:1433 microsoft/mssql-server-linux:2017-latest
Verify that your container is running
Replace the connection string in the project and update the database with your new database
Register to create a new user
Some helpful docker commands:
$ docker start <container>
– Start a container
$ docker stop <container>
– Stop a container
$ docker rm <container>
– Remove a container