ASP.NET Identity login

前端 未结 2 1463
予麋鹿
予麋鹿 2020-12-13 05:02

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

Now my partner needs to login a registered user in his WinForms app. Does a

2条回答
  •  孤城傲影
    2020-12-13 05:56

    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.

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

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

提交回复
热议问题