/// <summary> /// 退出登录的公共方法 /// </summary> /// <param name="userName">要退出登录的用户名</param> public void Logout(string userName) { if (StateProvider == null) { throw new ArgumentNullException("没有提供StateProvider,请提供实现了IStateProvider接口的登录提供程序。"); } if (!userName.IsEmpty()) { StateProvider.Logout(userName); FormsAuthentication.SignOut(); AppUser user = UserManager.GetByName(userName); if (user != null) { user.IsOnline = false; } } }