How can i assign role to a user in asp.net mvc3 application ?
i tried doing following
public ActionResult Login(LoginModel model)
{
if (ModelState.IsValid)
{
if (model.user_id == "admin" && model.password == "admin")
{
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1,
"admin",
DateTime.Now,
DateTime.Now.AddMinutes(30),
false,
"admin",
FormsAuthentication.FormsCookiePath);
return JavaScript("window.location.replace('/Home/');");
}
else
{
return Content("Invalid User Id or Password.");
}
}
else
{
return View(model);
}
}
Now when i try to get the user role in any views, it never gives me the role as admin. How do i assign role after login ?