Hi,
I want to redirect my page to different view based on user role after login.
I tried to use if else condition but it didn't work.
Here is my code
public ActionResult Login(CertModel login, string ReturnUrl = "")
{
using (certsEntities db = new certsEntities())
{
var v = db.tblUsers.Where(a => a.username == login.username && a.password==login.password).FirstOrDefault();
if (v != null)
{
FormsAuthentication.SetAuthCookie(v.username, false);
TempData["UserID"] = v.operator_id.ToString();
TempData["Username"] = v.username;
TempData["role"] = v.role;
if(v.role == "Admin")
{
return RedirectToAction("AdminIndex", "Home");
}
else
{
return RedirectToAction("Index", "Home");
}
}
else
{
ModelState.AddModelError("", "Incorrect Username or Password or User is no longer available.");
}
}
return View();
}