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); } } } } }