IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string virtualPath, string physicalPath) { // 说明:这里不使用virtualPath变量,因为不同的配置,这个变量的值会不一样。 // 例如:/mvc/*/*.aspx 和 /mvc/* // 为了映射HTTP处理器,下面直接使用context.Request.Path string requestPath = context.Request.Path; string vPath = UrlHelper.GetRealVirtualPath(context, requestPath); // 尝试根据请求路径获取Action InvokeInfo vkInfo = ReflectionHelper.GetActionInvokeInfo(vPath); // 如果没有找到合适的Action,并且请求的是一个ASPX页面,则按ASP.NET默认的方式来继续处理 if (vkInfo == null && requestPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase)) { if (_msPageHandlerFactory == null) _msPageHandlerFactory = new AspnetPageHandlerFactory(); // 调用ASP.NET默认的Page处理器工厂来处理 return _msPageHandlerFactory.GetHandler(context, requestType, requestPath, physicalPath); } return ActionHandler.CreateHandler(vkInfo); }
IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string virtualPath, string physicalPath) { // 说明:这里不使用virtualPath变量,因为不同的配置,这个变量的值会不一样。 // 例如:/mvc/*/*.aspx 和 /mvc/* // 为了映射HTTP处理器,下面直接使用context.Request.Path string requestPath = context.Request.Path; string vPath = UrlHelper.GetRealVirtualPath(context, requestPath); // 尝试根据请求路径获取Action InvokeInfo vkInfo = ReflectionHelper.GetActionInvokeInfo(vPath); // 如果没有找到合适的Action,并且请求的是一个ASPX页面,则按ASP.NET默认的方式来继续处理 if (vkInfo == null && requestPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase)) { if (_msPageHandlerFactory == null) { _msPageHandlerFactory = new AspnetPageHandlerFactory(); } // 调用ASP.NET默认的Page处理器工厂来处理 return(_msPageHandlerFactory.GetHandler(context, requestType, requestPath, physicalPath)); } return(ActionHandler.CreateHandler(vkInfo)); }
IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string virtualPath, string physicalPath) { // 说明:这里不使用virtualPath变量,因为不同的配置,这个变量的值会不一样。 // 例如:/mvc/*/*.aspx 和 /mvc/* // 为了映射HTTP处理器,下面直接使用context.Request.Path string requestPath = context.Request.Path; string vPath = UrlHelper.GetRealVirtualPath(context, requestPath); var data = PageUrl2ControllerTypeCache.DefaultPageUrl2ControllerTypeCache .GetDescriptor(PageUrlAttribute.ConvertToUniqueId(vPath, context.Request.HttpMethod)); // 如果没有找到合适的Action,并且请求的是一个ASPX页面,则按ASP.NET默认的方式来继续处理 if (data == null && requestPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase)) { if (_msPageHandlerFactory == null) { _msPageHandlerFactory = new AspnetPageHandlerFactory(); } // 调用ASP.NET默认的Page处理器工厂来处理 return(_msPageHandlerFactory.GetHandler(context, requestType, requestPath, physicalPath)); } RequestContext requestContext = new RequestContext(context, new Route(vPath) { UsePageUrlRoute = true, PageUrlData = data, Controller = data.Item1.Name, Action = data.Item2.Name }); return(new MvcHandlerBuilder().Create(requestContext)); }
IHttpHandler IHttpHandlerFactory.GetHandler(HttpContext context, string requestType, string virtualPath, string physicalPath) { // 尝试根据请求路径获取Action InvokeInfo vkInfo = ReflectionHelper.GetPageActionInvokeInfo(virtualPath); // 如果没有找到合适的Action,并且请求的是一个ASPX页面,则按ASP.NET默认的方式来继续处理 if( vkInfo == null && virtualPath.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase) ) { if( _msPageHandlerFactory == null ) _msPageHandlerFactory = new AspnetPageHandlerFactory(); // 调用ASP.NET默认的Page处理器工厂来处理 return _msPageHandlerFactory.GetHandler(context, requestType, virtualPath, physicalPath); } return ActionHandler.CreateHandler(vkInfo); }