webform 的路由
webform是怎么通过url找到对应handler的呢?
mvc 和webapi的路由都是通过注册到RouteTable.Routes中,然后在urlroutingmodule中路由到对应routehander,那以前webform程序没有注册路由又是怎么找到对应的handler的呢?
在httpapplication中注册事件中有一个MapHandlerExecutionStep
internal override void BuildSteps(WaitCallback stepCallback)
{
.......
arrayList.Add(new HttpApplication.MapHandlerExecutionStep(application));
...... }
在这个事件中
void HttpApplication.IExecutionStep.Execute()
{
........
context.Handler = this._application.MapHttpHandler(context, request.RequestType, request.FilePathObject, request.PhysicalPathInternal, false);
......
}
// System.Web.HttpApplication
internal IHttpHandler MapHttpHandler(HttpContext context, string requestType, VirtualPath path, string pathTranslated, bool useAppConfig)
{
IHttpHandler httpHandler = (context.ServerExecuteDepth == ) ? context.RemapHandlerInstance : null;
using (new ApplicationImpersonationContext())
{
if (httpHandler != null)
{
return httpHandler;
}
HttpHandlerAction handlerMapping = this.GetHandlerMapping(context, requestType, path, useAppConfig);
........
//根据请求信息包装对应工厂类并放入缓存中,每次从缓存中获取
IHttpHandlerFactory factory = this.GetFactory(handlerMapping);
try
{
//获取handler
IHttpHandlerFactory2 httpHandlerFactory = factory as IHttpHandlerFactory2;
if (httpHandlerFactory != null)
{
httpHandler = httpHandlerFactory.GetHandler(context, requestType, path, pathTranslated);
}
else
{
httpHandler = factory.GetHandler(context, requestType, path.VirtualPathString, pathTranslated);
}
}
.........
}
return httpHandler;
}
所以每次webform或者handler请求后都会从缓存中获取工厂类然后获取对应的handler
如何实现webform友好访问呢?
现在webform新建程序都会自动添加像mvc路由一样的路由注册文件
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}

public static class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
var settings = new FriendlyUrlSettings();
settings.AutoRedirectMode = RedirectMode.Permanent;
routes.EnableFriendlyUrls(settings);
}
}
webform 的路由的更多相关文章
- WebForm MapPageRoute 路由配置(转载)
使用场景是:MVC 混合使用 WebForm,然后对 WebForm 进行路由配置 http://www.cnblogs.com/xishuai/archive/2015/02/26/web-form ...
- WebForm MapPageRoute 路由配置
WebForm MapPageRoute 路由配置 MapPageRoute 应该是 ASP.NET 4.0 中的东西,但现在我是第一次使用它,使用场景是:MVC 混合使用 WebForm,然后对 ...
- ASP.NET WebForm 的路由
ASP.NET WebForm 的路由 偷会闲, 看看博客园, 有筒子写了篇: ASP.NET的路由 我翻了翻两前的一份邮件, 是我当时在项目之余的时间研究的,那时还没用MVC,所有项目都是 WebF ...
- ASP.NET WebForms MapPageRoute 路由配置
MapPageRoute 应该是 ASP.NET 4.0 中的东西,但现在我是第一次使用它,使用场景是:MVC 混合使用 WebForm,然后对 WebForm 进行路由配置,当然也可以使用 ISAP ...
- MVC中你必须知道的13个扩展点
MVC中你必须知道的13个扩展点 pasting 转:http://www.cnblogs.com/kirinboy/archive/2009/06/01/13-asp-net-mvc-extensi ...
- [转]ASP.NET MVC中你必须知道的13个扩展点
本文转自:http://www.cnblogs.com/ejiyuan/archive/2010/03/09/1681442.html ScottGu在其最新的博文中推荐了Simone Chiaret ...
- 13个不可不知的ASP.NET MVC扩展点
13个不可不知的ASP.NET MVC扩展点 ASP.NET MVC设计的主要原则之一是可扩展性.处理管线(processing pipeline)上的所有(或大多数)东西都是可替换的.因此,如果您不 ...
- ASP.NET MVC中你必须知道的13个扩展点
ScottGu在其最新的博文中推荐了Simone Chiaretta的文章13 ASP.NET MVC extensibility points you have to know,该文章为我 ...
- 13个 ASP.NET MVC 的扩展
ASP.NET MVC设计的主要原则之一是可扩展性.处理管线(processing pipeline)上的所有(或大多数)东西都是可替换的.因此,如果您不喜欢ASP.NET MVC所使用的约定(或缺乏 ...
随机推荐
- redis报错: redis.exceptions.ResponseError: value is not an integer or out of range
问题描述 今天在使用python的redis客户端时碰到了这样的报错:redis.exceptions.ResponseError: value is not an integer or out of ...
- 程序员代码面试指南 IT名企算法与数据结构题目最优解
原文链接 这是一本程序员面试宝典!书中对IT名企代码面试各类题目的最优解进行了总结,并提供了相关代码实现.针对当前程序员面试缺乏权威题目汇总这一痛点,本书选取将近200道真实出现过的经典代码面试题,帮 ...
- AtCoder abc 141 F - Xor Sum 3(线性基)
传送门 题意: 给出\(n\)个数\(a_i\),现在要将其分为两堆,使得这两堆数的异或和相加最大. 思路: 考虑线性基贪心求解. 但直接上线性基求出一组的答案是行不通的,原因之后会说. 注意到如果二 ...
- 开放接口的安全验证方案(AES+RSA)
http://wubaoguo.com/2015/08/21/%E5%BC%80%E6%94%BE%E6%8E%A5%E5%8F%A3%E7%9A%84%E5%AE%89%E5%85%A8%E9%AA ...
- 阿里云serverless使用笔记
1.使用api网关服务,创建完api后,测试时,需要传“请求签名”,否则会报401 ‘Empty Signature’错误.相关文档<错误编码表,请求签名>.(错误信息放置与响应头的‘x- ...
- [LeetCode] 43. Multiply Strings 字符串相乘
Given two non-negative integers num1 and num2represented as strings, return the product of num1 and ...
- 2019 SDN上机第2次作业
1.利用mininet创建如下拓扑,要求拓扑支持OpenFlow 1.3协议,主机名.交换机名以及端口对应正确,请给出拓扑Mininet执行结果,展示端口连接情况 1.1拓扑 1.2 代码 #!/us ...
- K8S 如何实现将git代码下拉到指定的容器路径中
gitRepo 是 kubernetes Volume类型中的一种,gitRepo volume可以实现将git代码下拉到指定的容器路径中. 备注:实现此功能,Pod运行的节点都必需要安装git.换句 ...
- firefly rk3399 增加 HL-340 驱动(编译内核)
前言:新下载了firefly rk3399 ubuntu固件16.04,但是发现没有HL-340 USB转串口的驱动,而机器人底盘驱动是HL-340的,所以一直提示无法找到设备驱动. 由于没有技术支持 ...
- Unity Shader 序列帧动画
shader中的序列帧动画属于纹理动画中的一种,主要原理是将给定的纹理进行等分,再根据时间的变化循环播放等分中的一部分. Unity Shader 内置时间变量 名称 类型 描述 _Time floa ...