public JsonResult Login(LoginModel loginModel) { logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: Login(HttpPost) - Begin"); ResponseDTO response = new ResponseDTO(); User currentuser = null; try { if (loginModel != null) { currentuser = dataaccess.GetCurrentUser(loginModel.UserName, loginModel.Password); if (currentuser != null) { if (currentuser.UserName == loginModel.UserName && currentuser.Password == loginModel.Password) { Session["CurrentUser"] = currentuser; response.IsSucess = true; FormsAuthentication.SetAuthCookie(loginModel.UserName, false); if (!String.IsNullOrEmpty(loginModel.ReturnUrl) && Url.IsLocalUrl(loginModel.ReturnUrl)) { response.ResponseMessage = loginModel.ReturnUrl; } else { response.ResponseMessage = ""; } } } else { response.ResponseMessage = "Incorrect User credentials"; response.IsSucess = false; } } } catch (Exception ex) { logginghelper.Log(LoggingLevels.Error, "Class: " + classname + " :: Login(HttpPost) " + ex); } logginghelper.Log(LoggingLevels.Info, "Class: " + classname + " :: Login(HttpPost) - End"); return(Json(response, JsonRequestBehavior.AllowGet)); }