ASP.NET身份登录 [英] ASP.NET Identity login

查看:148
本文介绍了ASP.NET身份登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC 5网站使用ASP.NET身份登录的用户。
一切都很正常。

I have a website in MVC 5 using ASP.NET Identity to login a user. Everything works great.

现在我的合作伙伴需要注册用户在他的WinForms应用程序登录。
有谁知道由标识使用的密码散列algorythm或者我怎么能在WinForms应用程序验证用户?

Now my partner needs to login a registered user in his WinForms app. Does anyone know the password hashing algorythm used by Identity or how can I authenticate the user in the WinForms app?

任何提示将是preciated。

Any tips would be apreciated.

最好的问候。

推荐答案

如果您使用的是从MVC应用程序Microsoft.AspNet.Identity.EntityFramework和WinForm的应用程序可以访问同一个数据库,那么你应该将其配置为使用同样的ConnectionString的MVC应用程序。
使用的NuGet添加Microsoft.AspNet.Identity.EntityFramework的WinForm应用程序。

If you are using Microsoft.AspNet.Identity.EntityFramework from the MVC app and the WinForm app has access to the same database, then you should configure it to use the same ConnectionString as the MVC application. Add Microsoft.AspNet.Identity.EntityFramework to the WinForm application using nuget.

然后将以下code可被用来验证用户名和密码:

Then the following code can be used to verify username and password:

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;
}

这篇关于ASP.NET身份登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆