.Net Core : AspNet Membership Login Method

.Net Core : AspNet Membership Login Method



AspNet membership login method code,

[HttpPost]
[Route("Login")]
public async Task<JsonResult> Post(VMLogin vmLogin)
{
Microsoft.AspNetCore.Identity.SignInResult result = new Microsoft.AspNetCore.Identity.SignInResult();
string errorMessage = "success";

if (ModelState.IsValid)
{
  
  result = await signInManager.PasswordSignInAsync(vmLogin.Email, vmLogin.Password, vmLogin.RememberMe, false);

if (!result.Succeeded)                 
{
errorMessage = "fail";
}
}

return Json(new { message = errorMessage });
} 



Hope this will help you and save your time.

Enjoy !!!

:)

No comments:

Post a Comment