how to store current user in ASP.NET Core MVC

404 Views Asked by At

I have a solution with the following projects in Visual Studio: - MVC client project that connects to API project - API project using using EF for idendity and for rest connect to Access project - Access project using dapper to connect to SQL db

When I go to the login page in the MVC project I can login by using the API service. In return I can get user information.

I want to use this user information to store so that when going to other pages in MVC and connecting again to the API, I can sent the token as authorization.

How would I store this token in MVC? Or is there a better approach for this?

I was reading that keeping this information in a session would be a risk.

1

There are 1 best solutions below

1
On BEST ANSWER

You will have to store token one way or another in the MVC application.

The most common way is to store it in sessionStorage and they add it to the Authorization header when calling the API on every request