Can someone help me with this. I am looking to put this code into a try catch. But I can't say how best to implement this:
public JsonResult JsonLogin(LoginModel model, string returnUrl)
{
if (ModelState.IsValid)
{
if (Membership.ValidateUser(model.UserName, model.Password))
{
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
return Json(new JsonDialog
{
Redirect = returnUrl,
Success = true
});
}
else
{
ModelState.AddModelError("", "The user name or password provided is incorrect.");
}
}
// If we got this far, something failed
return Json(new JsonDialog
{
Errors = GetErrorsFromModelState(),
Success = false
});
}
Should I put all of the code including the first "if" within the try catch?