void context_PostMapRequestHandler(object sender, EventArgs e) { HttpContext cont = ((HttpApplication)sender).Context; if (cont != null && QueryTool.IsCallMvc(cont.Request.Url) && !QueryTool.IsProxyCall(cont) && QueryTool.IsTaurusSuffix(cont.Request.Url)) { cont.Handler = SessionHandler.Instance;//注册Session } }
void context_Error(object sender, EventArgs e) { HttpContext cont = ((HttpApplication)sender).Context; if (cont != null && QueryTool.IsCallMvc(cont.Request.Url) && QueryTool.IsTaurusSuffix(cont.Request.Url)) { Log.WriteLogToTxt(cont.Error); } }
void context_AcquireRequestState(object sender, EventArgs e) { HttpContext cont = ((HttpApplication)sender).Context; if (cont != null && QueryTool.IsCallMvc(cont.Request.Url) && !QueryTool.IsProxyCall(cont) && QueryTool.IsTaurusSuffix(cont.Request.Url)) { CheckCORS(cont); ReplaceOutput(cont); InvokeClass(cont); } }
void context_BeginRequest(object sender, EventArgs e) { HttpApplication app = (HttpApplication)sender; HttpContext context = app.Context; Uri uri = context.Request.Url; #region 微服务检测与启动 string urlAbs = uri.AbsoluteUri; string urlPath = uri.PathAndQuery; string host = urlAbs.Substring(0, urlAbs.Length - urlPath.Length); MicroService.Run.Start(host);//微服务检测、启动。 if (!QueryTool.IsCallMicroServiceReg(uri) && MicroService.Run.Proxy(context, true)) { QueryTool.SetRunProxySuccess(context); try { context.Response.End(); } catch (ThreadAbortException) { } return; } #endregion if (QueryTool.IsCallMvc(uri)) { if (context.Request.Url.LocalPath == "/")//设置默认首页 { string defaultUrl = QueryTool.GetDefaultUrl(); if (!string.IsNullOrEmpty(defaultUrl)) { context.RewritePath(defaultUrl); return; } } if (QueryTool.IsTaurusSuffix(uri)) { MethodInfo routeMapInvoke = MethodCollector.RouteMapInvokeMethod; if (routeMapInvoke != null) { string url = Convert.ToString(routeMapInvoke.Invoke(null, new object[] { context.Request })); if (!string.IsNullOrEmpty(url)) { context.RewritePath(url); } } } } }