Arjun Dhilod

Arjun Dhilod

  • 958
  • 812
  • 106.1k

An error occurred while processing your request. MVC 4

Jun 7 2018 7:47 AM
 
 
[AllowAnonymous]
public ActionResult Login(string returnUrl)
{
try
{
ViewBag.Success = TempData["Message"];
LoginModel model = new LoginModel();
if ((User.Identity as SimpleIdentity) != null)
{
if ((User.Identity as SimpleIdentity).IsAdministrator || (User.Identity as SimpleIdentity).RoleName.ToLower() == "admin")
{
return RedirectToAction("AdminView", "Admin");
}
else if ((User.Identity as SimpleIdentity).RoleName.ToLower() == "dietitian")
{
return RedirectToAction("DieticianView", "Admin");
}
return RedirectToAction("Index", "Dashboard");
}
if (HttpContext.Request.Cookies["RememberMe"] != null)
{
model.UserName = HttpContext.Request.Cookies["RememberMe"]["UserName"];
model.Password = BaseModel.Decrypt(HttpContext.Request.Cookies["RememberMe"]["Password"]);
model.RememberMe = Convert.ToBoolean(HttpContext.Request.Cookies["RememberMe"]["Rememberme"]);
}
ViewBag.ReturnUrl = returnUrl;
return View(model);
}
catch (Exception ex)
{
logger.Error(ex.Message, ex);
return View("Error");
}
}
 
i am new in MVC i am getting above error  when saving cookies  pls check and let me know if some know the solution  

Answers (2)