private void context_BeginRequest(object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; application.Context.Response.ContentType = "text/xml"; application.Context.Response.Write("<?xml version='1.0' encoding='utf-8' ?>"); string auth = application.Context.Request["auth"]; if (string.IsNullOrEmpty(auth)) { application.CompleteRequest(); application.Context.Response.Write(ClientUtils.FormatErrorMsg("没有权限查看")); } var host = application.Context.Request["SERVER_NAME"]; var forbidden = true; if (_host.ContainsKey(host)) { forbidden = _host[host]; } if (forbidden) { var fb = application.Context.Request["fb"]; if (fb != null && _host.ContainsKey(fb)) { forbidden = _host[fb]; } } application.Context.Items.Add("forbidden", forbidden); }
private void context_Error(object sender, EventArgs e) { HttpApplication application = sender as HttpApplication; Exception ex = application.Context.Server.GetLastError(); logger.Error(ex); application.Context.Response.Write(ClientUtils.FormatErrorMsg(ex.Message)); application.Context.Server.ClearError(); }
public override void ProcessRequest(System.Web.HttpContext context) { //context.Response.ContentType = "text/xml"; //context.Response.Write("<?xml version='1.0' encoding='utf-8' ?>"); context.Response.Write(ClientUtils.FormatErrorMsg(_msg)); }