ASP.NET身份登录

 mobiledu2502862707 发布于 2023-02-06 11:51

我在MVC 5中有一个使用ASP.NET Identity登录用户的网站.一切都很好.

现在我的合作伙伴需要在他的WinForms应用程序中登录注册用户.有谁知道Identity使用的密码哈希算法或如何在WinForms应用程序中验证用户?

任何提示都会被贬低.

最好的祝福.

1 个回答
  • 如果您使用MVC应用程序中的Microsoft.AspNet.Identity.EntityFramework并且WinForm应用程序可以访问同一个数据库,那么您应该将其配置为使用与MVC应用程序相同的ConnectionString.使用nuget将Microsoft.AspNet.Identity.EntityFramework添加到WinForm应用程序.

    然后,以下代码可用于验证用户名和密码:

    public async Task<bool> VerifyUserNamePassword(string userName, string password)
    {
       var usermanager = new UserManager<IdentityUser>(new UserStore<IdentityUser>(new IdentityDbContext()));
       return await usermanager.FindAsync(userName, password) != null;
    }
    

    2023-02-06 11:53 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有