I'm using default forms authentication implementation in ASP.NET MVC 4.
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
{
//Assign additional data
return RedirectToLocal(returnUrl);
}
// If we got this far, something failed, redisplay form
ModelState.AddModelError("", "The user name or password provided is incorrect.");
return View(model);
}
This works fine. I need to pass some additional data of each logged in user, to use later, without accessing the database again. (ex: user roles and role details)
Is there any implementation in WebSecurity to do this without using Session variable?
you can use this method to additional values and parameter websecurity method :
Typically you would have additional values to be stored at the time of user registration using the code
You can add multiple properties in the anonymous object
WebSecurity.Login
takes only 2 parameters to login an existing user