ASP.NET中HttpApplication中ProcessRequest方法中运行的事件顺序

1.BeginRequest  開始处理请求

2.AuthenticateRequest 授权验证请求,获取用户授权信息
3.PostAuthenticateRequest 获取成功
4.AunthorizeRequest 授权,一般来检查用户是否获得权限
5.PostAuthorizeRequest 获得授权
6.ResolveRequestCache 获取页面缓存结果(假设没有则运行)
7.PostResolveRequestCache 已获取缓存
8.PostMapRequestHandler 创建页面对象
9.AcquireRequestState 获取Session -- 先推断当前页面对象是否实现了IRequiresSessionState接口,假设实现了,则从浏览器发来的请求报文头中获得SessionId,并到server的 Session池中获得相应的Session对象,最后赋值给 HttpContext的Session属性。
10.PostAcquireRequestState 获得Session
11.PreRequestHandlerExecute 准备运行页面对象
×运行页面对象的ProcessRequest方法(1.ashx,1.aspx)。假设请求的是1.aspx。则会运行页面生命周期
12.PostRequestHandlerExecute 运行完页面对象了
13.ReleaseRequestState 释放请求状态
14.PostReleaseRequestState 已释放请求状态
15.UpdateReuqestCache 更新缓存
16.PostUpdateRequestCache 已更新缓存
17.LogRequest 日志记录
18.PostLogRequest 已完毕日志

19.EndRequest 完毕

能够再Global.asax中加入以Application_为前缀+事件名 的方法运行測试!比如:

 public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas(); WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
} public void Application_BeginRequest(object sender, EventArgs e)
{
HttpApplication obj = sender as HttpApplication;
obj.Context.Response.Write("1 Application_BeginRequest<br/>");
} public void Application_ResolveRequestCache(object sender, EventArgs e)
{
HttpApplication obj = sender as HttpApplication;
obj.Context.Response.Write("6 Application_ResolveRequestCache<br/>");
} public void Application_PostResolveRequestCache(object sender, EventArgs e)
{
HttpApplication obj = sender as HttpApplication;
obj.Context.Response.Write("7 Application_PostResolveRequestCache<br/>");
}
public void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
HttpApplication obj = sender as HttpApplication;
obj.Context.Response.Write("11 Application_PreRequestHandlerExecute<br/>");
}
}
}

下面附上MVC总体请求流程图。来自传智播客黑马培训班

ASP.NET WebForm总体请求流程图,来自传智播客黑马培训班

ASP.NET中HttpApplication中ProcessRequest方法中运行的事件顺序;ASP.NET WebForm和MVC总体请求流程图的更多相关文章

  1. CI控制器中设置在其它方法中可用的变量

    开发过程中,某些变量可能需要被控制器中的其它方法所调用,这个变量改怎么设置呢? 其实可以用ci的$this->load->vars($array);和$this->load-> ...

  2. ios中怎么样设置drawRect方法中绘图的位置

    其中drawRect方法中的参数rect就是用来设置位置的,

  3. rails中weill_paginate的paginate方法中不能使用额外参数的解决办法

    我们知道高版本中的rails中的分页功能已经放在will_paginate这个gem中,我们在控制器方法中往往需要调用其paginate方法来实现分页数据集控制,举个例子:正常的情况我们想要每页显示1 ...

  4. 我的Android进阶之旅------>android中service的onStartCommand()方法中intent为null的问题

    今天在维护公司的一个APP的时候,突然爆了空指针异常, Caused by: java.lang.NullPointerException: Attempt to invoke virtual met ...

  5. java——ArrayList中contains()方法中的疑问

    问题引子: ist<Student> students=new ArrayList<Student>(); students.add(new Student("201 ...

  6. pandas中DataFrame对象to_csv()方法中的encoding参数

    当使用pd.read_csv()方法读取csv格式文件的时候,常常会因为csv文件中带有中文字符而产生字符编码错误,造成读取文件错误,在这个时候,我们可以尝试将pd.read_csv()函数的enco ...

  7. 去除myeclipse中doget和dopost方法中的注释

    当我们使用myeclipse新建servlet时发现doget和dopost方法中有一些无用的注释,每次新建一个servlet时都要手动删除特别麻烦. 下面就教大家如何去除这些注释! 以myeclip ...

  8. EF中使用Select new 方法中字段值替换的问题

    前提需要替换查询得到的List当中的某个字段的值,替换规则有一个mapping关系 尝试代码 有问题 无法获取任何数据 /// <summary> /// 获取Treegrid的List ...

  9. C#委托的用法 在C#中我想在一个方法中调用另一个按钮的事件,怎样来实现?

    最开始我也不清楚,后来我是这样想了. 1.事件和委托不是一个概念,你如果是调用control的事件,可以直接在其对应的事件eventhandler上attach自己的事件方法就好了如:this.But ...

随机推荐

  1. 3DLut表实现log视频的后期调色原理

    现在越来越多的视频或者图像拍摄设备支持log模式,比如大疆无人机的D-Log模式等等,log模式的起源和发展就不多做介绍,其在普通显示器上显示画面通常看起来是平坦的灰色,因此也常被称为log灰视频. ...

  2. SpringMVC+jquery.uploadify 上传文件

    前言 以前用Asp.net MVC+uploadify上传文件,最近学习SpringMVC,所以就用SpringMVC+uploadify做个上传文件的demo. 刚开始用form表单的方式提交,在C ...

  3. Linux问题杂谈

    1. 虚拟机 SSH 无法登录 1.1 问题1:未安装ssh服务端 ssh: connect to host 192.168.58.129 port 22: Connection refused 问题 ...

  4. 声明父类new子类

    基本概念 这个实例是子类的,但是因为你声明时是用父类声明的,所以你用正常的办法访问不到子类自己的成员,只能访问到从父类继承来的成员. 在子类中用override重写父类中用virtual申明的虚方法时 ...

  5. Mysql常用函数总结(二)

    有的时候们需要了解当前的时间,这时候我们就可以调用时间函数了.下面就是一些常用的时间函数下面来说一下DATE_FORMAT(date,format):format可以有以下格式符:举个例子吧! mys ...

  6. MATLAB indexing question

    Question: I have a matrix, for example A = [ 1 2 3; 4 5 6; 7 8 9] ; and a vector of size 1x3 which s ...

  7. 移动端FastClick和editor冲突问题。

        FastClick.prototype.needsClickForParent = function (target) {         let parent = target.parent ...

  8. JqGrid: Add,Edit,Del in asp.net

    https://github.com/1rosehip/jplist https://github.com/free-jqgrid/jqGrid https://plugins.jquery.com/ ...

  9. 【代码笔记】Web-利用Dreamweaver实现表格

    一,打开Dreamweaver---->File---New---->如下图所示.选择HTML,点击OK. 二,会出现如下图所示界面.把光标放到Body处. 三,Insert---> ...

  10. loadrunner 运行脚本-Run-time Settings->General->Additional attributes设置

    运行脚本-Run-time Settings->General->Additional attributes设置 by:授客 QQ:1033553122 作用说明 为Vuser脚本提供额外 ...