[杂] ASP.NET MVC 之 Route To MvcHandler
2024-08-26 02:50:42
首先,本文参考了不少东东,仅供Q_L_H自己使用,ZZ自己负责。先上一张全家福:
HttpModules and HttpHandlers
ASP.NET MVC 是 HttpHandler.
UrlRoutingModule 是 HttpModule, 在web.config里面注册。
UrlRoutingModule → MvcRouteHandler
MvcRouteHandler → MvcHandler
IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext) { return this.GetHttpHandler(requestContext); } protected virtual IHttpHandler GetHttpHandler(RequestContext requestContext) { requestContext.HttpContext.SetSessionStateBehavior(this.GetSessionStateBehavior(requestContext)); return (IHttpHandler) new MvcHandler(requestContext); }
MvcHandler → IController
private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory) { HttpContext current = HttpContext.Current; if (current != null) { bool? nullable = ValidationUtility.IsValidationEnabled(current); if ((!nullable.GetValueOrDefault() ? 0 : (nullable.HasValue ? 1 : 0)) != 0) ValidationUtility.EnableDynamicValidation(current); } this.AddVersionHeader(httpContext); this.RemoveOptionalRoutingParameters(); string requiredString = this.RequestContext.RouteData.GetRequiredString("controller"); factory = this.ControllerBuilder.GetControllerFactory(); controller = factory.CreateController(this.RequestContext, requiredString); if (controller != null) return; throw new InvalidOperationException(string.Format((IFormatProvider) CultureInfo.CurrentCulture, MvcResources.ControllerBuilder_FactoryReturnedNull, new object[2] { (object) factory.GetType(), (object) requiredString })); }
参考文章:
http://www.codeproject.com/Articles/595520/MvcRouteHandler-and-MvcHandler-in-ASP-NET-MVC-Fram
http://beletsky.net/2011/06/inside-aspnet-mvc-route-to-mvchanlder.html
http://msdn.microsoft.com/en-us/magazine/dd695917.aspx
最新文章
- 转载:Spring AOP (下)
- JS中跨域和沙箱的解析
- HTML插入地图的方法
- PHP时间日期
- LeetCode: Lowest Common Ancestor of a Binary Search Tree 解题报告
- Report_报表中Ref Cursor数据源的概念和用法(案例)
- 修改Win7远程桌面端口
- Josephina and RPG
- Web移动端Fixed布局的解决方案
- 基于纹理边缘抑制的轮廓和边界检测(Contour and Boundary Detection)
- 配置F5 负载均衡(转)
- javascript深入理解js闭包(转载)
- python之模块、包的导入过程和开发规范
- Luogu3676 小清新数据结构题(树链剖分+线段树)
- Flex 布局教程转载
- ab,qps 并发连接数
- jsp里面不能使用${pageContext.request.contextPath}解决方案
- 【胡思乱想】JNI与线程池的维护
- [原]F5负载均衡激活license
- 用js内置对象XMLHttpRequest 来用ajax