public ActionResult Logout() { try { ILogger logger = new Logger(this.GetType()); IWebUserService webUserService = new WebUserService(); string userName = Session[SessionKey] as string; if (userName != null) { webUserService.Logout(userName); } Session.Clear(); logger.Info("User '" + userName + "' has logged out."); string LoginMsg = webUserService.GetLoginMsgText(); ViewData["CustomMsg"] = LoginMsg; return(View("Login")); } catch (Exception ex) { logger.Error("Exception in UserController", ex); // Redirect to error page Response.Redirect("Result/error"); return(null); } }
public ActionResult Logout() { try { IWebUserService userService = new WebUserService(); string userName = Session[SessionKey] as string; if (userName != null) { userService.Logout(userName); } Session.Clear(); logger.Info("User '" + userName + "' has logged out."); ISettingsService settingsService = new SettingsService(); string loginMessage = settingsService.GetLoginMsgText(); if (loginMessage == null) { logger.Warn("loginMessage is null (logout case)."); } ViewData["CustomMsg"] = loginMessage; return(View("Login")); } catch (Exception ex) { logger.Error("Exception occurred while logging out.", ex); // Redirect to error page Response.Redirect(AppHelper.SharedUrl("Result/Error")); return(null); } }