简体   繁体   English

无法使用 asp.net 核心身份登录

[英]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.但是,当我尝试登录使用 Identity 创建的网站时,什么也没有发生。 All the tables are in my database as it should be.所有的表都在我的数据库中。

In the output in visual studio it says:在 Visual Studio 的 output 中它说:

info: GetThingsDoneMVC.Areas.Identity.Pages.Account.RegisterModel[0] User created a new account with password.信息:GetThingsDoneMVC.Areas.Identity.Pages.Account.RegisterModel[0] 用户使用密码创建了一个新帐户。

info: GetThingsDoneMVC.Areas.Identity.Pages.Account.LoginModel[0] User logged in.信息:GetThingsDoneMVC.Areas.Identity.Pages.Account.LoginModel[0] 用户登录。

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?关于如何解决这个问题的任何想法?

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.我过去也有过,问题是我没有将@inject SignInManager<Identity> SignInManager@inject UserManager<Identity> UserManager_LoginPartial.cshtml文件中。 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.如果您有单独的模型项目,还要确保在_ViewImports.cshtml文件中添加了@using Microsoft.AspNetCore.Identity@using Myproject.Models

I fix the issue by going to the startup.cs and changing我通过转到 startup.cs 并更改来解决问题

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

to

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 不能在 ASP.NET 核心中使用我的 MySql 数据库和身份 - cant use my MySql database in ASP.NET Core with Identity 外部登录不工作身份服务器 4 asp.net 核心 - External login not working Identity server 4 asp.net core 部署后 ASP.Net Core Identity 登录状态丢失 - ASP.Net Core Identity login status lost after deploy Asp.Net Core Identity 核心注册 - Asp.Net Core Identity Core Registration asp.net核心身份提取并保存外部登录令牌并添加对本地身份的声明 - asp.net core identity extract and save external login tokens and add claims to local identity Asp.net 核心身份登录成功重定向回登录页面 - Asp.net core Identity successful login redirecting back to login page 在MVC中使用Asp.Net Core Identity,成功登录后,Authorize属性会重新启动到登录页面 - Using Asp.Net Core Identity in MVC, Authorize attribute is rebouncing to login page after succesfull login 使用 Identity Core 在 ASP.Net Core 2.1 中登录后立即添加重定向 - Adding Redirection immediately after Login in ASP.Net Core 2.1 using Identity Core ASP.Net身份-无法使用密码登录 - ASP.Net Identity - cannot login with password Asp.net身份-记录每次登录 - Asp.net Identity - log each login
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM