Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant login with asp.net core Identity

So I am working on a project. Everything seems fine. I dont have any error or anything like that. But when I am trying to login into my website that I created with Identity, nothing happens. All the tables are in my database as it should be.

In the output in visual studio it says:

info: GetThingsDoneMVC.Areas.Identity.Pages.Account.RegisterModel[0] User created a new account with password.

info: GetThingsDoneMVC.Areas.Identity.Pages.Account.LoginModel[0] User logged in.

So it works. But when I try to login nothing happens. I get redirected to the home page and I still don't see that I am logged in. It still says up in the corner "Register" and "Login".

Have anyone else had this problem before? Any idea on how to fix this?

like image 990
Joro Avatar asked Dec 06 '25 20:12

Joro


2 Answers

I also had it in the past and the problem was that I did not add @inject SignInManager<Identity> SignInManager and @inject UserManager<Identity> UserManager to the _LoginPartial.cshtml file. Also make sure that in the _ViewImports.cshtml file you have added @using Microsoft.AspNetCore.Identity and @using Myproject.Models if you have a seperate models project.

like image 102
bertilvandekerkhove Avatar answered Dec 08 '25 11:12

bertilvandekerkhove


I fix the issue by going to the startup.cs and changing

services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = true)

to

services.AddDefaultIdentity(options => options.SignIn.RequireConfirmedAccount = false)

like image 23
Kenny Luong Avatar answered Dec 08 '25 11:12

Kenny Luong