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所使用的约定(或缺乏 ...
随机推荐
- FollowUp CRM是什么,有什么作用,好不好
FollowUp,基于Gmail的私人CRM: 是一款Chrome插件,构建在Gmail邮箱服务之上: FollowUp支持通过Gmail:设置提醒,编写备注,计划会议,查看下一步的内容等: Foll ...
- Linux---进程控制类命令
1.查看系统中的进程命令 (1)ps (2)top 2.控制系统中的进程命令 (1)kill (2)killall (3)nice (4)renice 3.进程后台运行命令 (1)& 4.进程 ...
- MLflow安装配置初入门
学习这个时,要和Kubeflow作比较, 看看它们俩在解决和规范机器学习流程方面的思路异同. mlflow三大内涵: Tracking, Projects, Models. 一,基础镜像 harbor ...
- HTML与CSS学习笔记(1)
1.web三大核心技术? HTML CSS JavaScript 2.HTML基本机构和属性 HTML:超文本 标记 语言 超文本:文本内容+非文本内容(图片.视频.音频等) 标记:<单词> ...
- chm帮助文档显示字体过小
问题描述: 在查看chm帮助文档时,发现默认显示字体过小,阅读吃力 解决方案: 1. 点击选项按钮->Internet 选项 2. 点击辅助功能 3. 选中 忽略网页上指定的字号,点击确定 最后 ...
- python SSL 错误
python 使用pip 安装模块是提示SSL错误 出现该问题的原因由于系统的openssl是1.0.1的版本,对于python3.7太老了,需要更新为openssl1.0.2或者libressl2. ...
- (translation.E004) You have provided a value for the LANGUAGE_CODE setting that is not in the LANGUAGES setting.
django3.0开始LANGUAGE_CODE前面必须配相应的LANGUAGES配置如下: from django.utils.translation import gettext_lazy as ...
- 批处理命令 call
call 命令 CALL命令可以在批处理执行过程中调用另一个批处理,当另一个批处理执行完后,再继续执行原来的批处理 CALL command 调用一条批处理命令,和直接执行命令效果一样,特殊情况下很有 ...
- tuned linux 性能调优工具
tuned 是redhat 提供的一套系统调优工具,使用简单,同时也提供了比较全的分类. 参考资料 https://github.com/redhat-performance/tuned
- leetcode组合总和 Ⅳ 解题路径
题目: 关于动态规划类题目的思路如何找在上一篇博客 https://www.cnblogs.com/niuyourou/p/11964842.html 讲的非常清楚了,该博客也成为了了leetcode ...