//---------------------------------------------- // 解析和获取处理器 //---------------------------------------------- public static void HandlerHttpApiRequest(HttpContext context) { var req = context.Request; var uri = req.Url; var url = uri.AbsolutePath.ToLower(); object handler = null; // 获取处理器对象 if (url.StartsWith("/httpapi/")) { // 以 /HttpApi/Type/Method 方式调用 var typeName = HttpApiHelper.GetRequestTypeName(); handler = TryGetHandlerFromCache(typeName); if (handler == null) { handler = TryCreateHandlerFromAssemblies(typeName); } } else { // 以 Page.aspx/Method 方式调用 int n = url.LastIndexOf("/"); url = url.Substring(0, n); Type type = WebHandlerParser.GetCompiledType(url, url, context); handler = Activator.CreateInstance(type); } // 调用处理器方法 if (handler != null) { HttpApiHelper.ProcessRequest(context, handler); DisposeIfNeed(handler); } }
public override void ProcessRequest(HttpContext context) { bool hasPathInfo = !string.IsNullOrEmpty(context.Request.PathInfo); if (hasPathInfo) { // web方法调用请求 HttpApiHelper.ProcessRequest(context, this); } else { // 普通页面请求(给页面上附加上<script>标签) this.Load += (s2, e2) => { RegistJs(this); }; base.ProcessRequest(context); } }
//---------------------------------------------- // 解析和获取处理器 //---------------------------------------------- public static void HandlerHttpApiRequest(HttpContext context) { // 根据请求路径获取类型名:去掉扩展名;去前缀;用点运算符; // 获取处理器对象(从程序集创建或从缓存获取),处理web方法调用请求。 var typeName = HttpApiHelper.GetRequestTypeName(); var handler = TryGetHandlerFromCache(typeName); if (handler == null) { handler = TryCreateHandlerFromAssemblies(typeName); } if (handler != null) { HttpApiHelper.ProcessRequest(context, handler); DisposeIfNeed(handler); } }
public void ProcessRequest(HttpContext context) { HttpApiHelper.ProcessRequest(context, this); }