public void ProcessRequest(HttpContext context) { HttpRequest request = HttpContext.Current.Request; URLoginService loginService = new URLoginService(); try { string logoutString = request.QueryString["logout"]; bool logout = false; if (!string.IsNullOrEmpty(logoutString) && bool.TryParse(logoutString, out logout) && logout) { loginService.Logout(); if (!string.IsNullOrEmpty(request.QueryString["ReturnUrl"])) { HttpContext.Current.Response.Redirect(request.QueryString["ReturnUrl"]); } else { HttpContext.Current.Response.Redirect(FormsAuthentication.DefaultUrl); } } else { loginService.Login(); } } catch (ThreadAbortException) { } catch (ToUserException ex) { HttpContext.Current.Response.Write("alert('" + ex.Message.Replace("'", "\\'") + "');location='" + request.Url + "&ReturnUrl=" + HttpContext.Current.Server.UrlEncode(request.QueryString["ReturnUrl"]) + "';"); } catch (Exception ex) { LogHelper.WriteException("net91com.Stat.Web", ex); HttpContext.Current.Response.Write("alert('系统错误,请稍候再试...');location='" + request.Url + "&ReturnUrl=" + HttpContext.Current.Server.UrlEncode(request.QueryString["ReturnUrl"]) + "';"); } }
public void DoYes() { loginService.Logout(); Response.Redirect("Login.aspx"); }