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所使用的约定(或缺乏 ...
随机推荐
- Django 练习班级管理系统二 -- 添加班级数据
在上一篇中(Django 练习班级管理系统一 https://www.cnblogs.com/klvchen/p/11078174.html),使用的是莫泰对话框的方式提交数据,适用于数据量少的操作. ...
- linux 线程基础
线程基础函数 查看进程中有多少个线程,查看线程的LWP ps -Lf 进程ID(pid) 执行结果:LWP列 y:~$ ps -Lf 1887 UID PID PPID LWP C NLWP STIM ...
- C语言结构体(摘抄C语言设计)
struct Student stu_1;//定义struct Student 类型的变量stu_1 struct Student *p;//定义指向struct Student类型数据的指针变量 p ...
- 习题6-4 使用函数输出指定范围内的Fibonacci数
#include<stdio.h> int fib(int n); void PrintFN(int m, int n); int main(void) { int m, n, t; sc ...
- Logback文件这么配置,TPS提高至少10倍
来源:https://tinyurl.com/y5zbtgsq 阅读本文,你将了解到 日志输出到文件并根据LEVEL级别将日志分类保存到不同文件 通过异步输出日志减少磁盘IO提高性能 异步输出日志的原 ...
- Spring Cloud Alibaba Sentinel 的配置选项:spring.cloud.sentinel.transport.port,默认值:8719
spring.cloud.sentinel.transport.port 端口配置会在应用对应的机器上启动一个 Http Server,该 Server 会与 Sentinel 控制台做交互.比如 S ...
- spring cloud各个微服务之间如何相互调用(Feign、Feign带token访问服务接口)
1.首先先看什么是Feign. 这里引用“大漠知秋”的博文https://blog.csdn.net/wo18237095579/article/details/83343915 2.若其他服务的接口 ...
- 日常笔记5C/C++快速入门一些基础细节
一.变量数据类型 int大致范围:-210^9~210^9 long long大致范围:-910^18~910^18,对于长整型来说,如果赋值大于2^31-1的初值,就需要在初值后面加上LL,否则会编 ...
- Python数据分析与爬虫
数据分析重要步骤: 1.数据获取 可以进行人工收集获取部分重要数据 可以在各个数据库中导出数据 使用Python的爬虫等技术 2.数据整理 从数据库.文件中提取数据,生成DataFrame对象 采 ...
- ES方法使用注意
matchQuery:会将搜索词分词,再与目标查询字段进行匹配,若分词中的任意一个词与目标字段匹配上,则可查询到. termQuery:不会对搜索词进行分词处理,而是作为一个整体与目标字段进行匹配 ...