IIS 7.0, ASP.NET, pipelines, modules, handlers, and preconditions
Conceptually, the IIS pipeline is a state machine with the following states:
BEGIN_REQUEST
AUTHENTICATE_REQUEST
AUTHORIZE_REQUEST
RESOLVE_REQUEST_CACHE
MAP_REQUEST_HANDLER
ACQUIRE_REQUEST_STATE
PRE_EXECUTE_REQUEST_HANDLER
EXECUTE_REQUEST_HANDLER
RELEASE_REQUEST_STATE
UPDATE_REQUEST_CACHE
LOG_REQUEST
END_REQUEST
When a request is received, it moves through the state machine
step-by-step until completion. Beginning with IIS 7.0, users can
register their own code to be executed within any or all of the steps.
This code is referred to as a module. In other words, users register
modules to handle events in the pipeline. (I will refer to the stages
of the pipeline as steps, events, notifications, and sometimes
combinations of one or more of these. Don't let that confuse you. They
all mean the same thing.)
2.0 Integrated vs. Classic Pipeline Modes
IIS 7.0 has two pipeline modes: integrated and classic. The latter is sometimes referred to as ISAPI mode.
Integrated mode allows both managed and native modules to register
for events in the IIS pipeline. This enables many new scenarios, such
as applying ASP.NET forms authentication to non-asp.net requests (static
files, classic ASP files, etc).
Classic mode is identical to IIS 6.0. In classic mode, the ASP.NET
pipeline (BeginRequest, AuthenticateRequest,…, EndRequest) runs entirely
within the IIS pipeline’s EXECUTE_REQUEST_HANDLER event. Think of ASP.NET in classic mode as a pipeline within a pipeline.
3.0 Handlers vs. Modules
Modules are units of code that have registered for one or more
pipeline events. They perform authentication, authorization, logging,
etc. There is one task that is reserved for a special module, known as a
handler. The handler’s unique job is to retrieve the resource that is
requested in the URL. All resources served by IIS are mapped to a
handler in configuration. If the configuration mapping does not exist,
requests for the resource will receive a 404 HTTP status. In addition
to the configuration mapping, which takes place before the pipeline
begins, the handler mapping can be changed during request execution in
the MAP_REQUEST_HANDLER event. This allows scenarios such as URL
rewriting to work. Handlers are notified, or executed, in the EXECUTE_REQUEST_HANDLER step. (Note that only the mapped handler is notified, as you would expect.)
4.0 Handler and Module Configuration
IIS 7.0 introduces two new configuration sections: <handlers>
and <modules>. The ASP.NET <httpHandlers> and
<httpModules> sections still exist, but are only used when running
in the classic pipeline mode. The new IIS sections add a level of
complexity which many users find confusing.
First, if you're running in classic mode, your application should not
require any changes. The standard extensions served by ASP.NET ASPX,
ASMX, AXD, etc are mapped to a handler in IIS configuration that invokes
aspnet_isapi.dll and executes managed code just like it does on IIS 6.
If, however, you made changes to the IIS script mappings on IIS 6, you
will need to make corresponding changes in IIS 7. This will involve
adding a <handler> mapping.
On the other hand, if you're running in integrated mode, you will
need to migrate your <httpHandler> and <httpModule> sections
to the new <handler> and <module> sections. For example,
you can use the following command to migrate the <httpModules>
section for the default web site:
%WINDIR%/system32/inetsrv/appcmd migrate config "Default Web Site/" -section:httpModules
The confusion occurs right about the time you start wondering how to
add a managed module to the integrated pipeline that only executes for
managed requests. Or when you need to add a handler mapping that only
applies to the integrated pipeline. To perform these type actions, IIS
uses preconditions on the module or handler to restrict the conditions
under which it executes.
For handlers, if you set preCondition="integratedMode" in the <handler> mapping, the handler will only run in integrated mode. On the other hand, if you set preCondition="classicMode"
the handler will only run in classic mode. And if you omit both of
these, the handler can run in both modes, although this is not possible
for a managed handler.
For modules, if you set preCondition=”managedHandler”
in the <module> entry, the module will only run for managed
requests (a managed request is a request that has a managed handler).
If you omit this, the module will run for all requests. Managed modules
in the <modules> section are only called if you're running in the
integrated pipeline. If you're running in classic mode, then
<httpModules> is used.
Note that the “integratedMode” and “classicMode” preconditions only
apply to handlers, and the “managedHandler” precondition only applies to
modules. Also note that there are other preconditions that we have not
discussed here. These can be used to restrict the handler or module to a
version of the framework, or specific processor architecture (32-bit or
64-bit), for example.
The ASP.NET <httpHandlers> section has no knowledge of
preconditions, and so you should never use them there. The same is true
for <httpModules>.
5.0 Troubleshooting
If you receive an error similar to the one below, your <handler> section is probably invalid.
HTTP Error 500.21 - Internal Server Error
Handler "<HANDLER_NAME>" has a bad module "ManagedPipelineHandler" in its module list
You probably have a handler mapping that does not have the correct
precondition. IIS is not forgiving in regard to typos, and
preconditions are case-sensitive. The text must be preCondition=”integratedMode” or preCondition=”classicMode”.
IIS 7.0, ASP.NET, pipelines, modules, handlers, and preconditions的更多相关文章
- iis 7.0 asp.net发布问题
问题1: 配置错误:不能在此路径中使用此配置节.如果在父级别上锁定了该节,便会出现这种情况.锁定是默认设置的………… 解决方案: 因为 IIS 7 采用了更安全的 web.config 管理机制,默认 ...
- ASP.NET的运行原理与运行机制 如何:为 IIS 7.0 配置 <system.webServer> 节
https://technet.microsoft.com/zh-cn/sysinternals/bb763179.aspx 当一个HTTP请求到服务器并被IIS接收到之后,IIS首先通过客户端请求的 ...
- IIS 7.0 的 ASP.NET 应用程序生命周期概述(转载)
IIS 7.0 的 ASP.NET 应用程序生命周期概述更新:2007 年 11 月本主题介绍在 IIS 7.0 集成模式下运行以及与 IIS 7.0 或更高版本一起运行的 ASP.NET 应用程序的 ...
- ASP.NET MVC3 系列教程 - 部署你的WEB应用到IIS 6.0
I:ASP.NET MVC3 部署的前期工作 1.确认部署的服务器操作系统环境 首先我们确认服务器的操作系统版本 可以从系统命令行工具里输入: systeminfo 获取相关操作系统信息例如 然后再确 ...
- Local IIS 7.0 - CS0016: Could not write to output file / Microsoft.Net > Framework > v4.0.30319 > Temporary ASP.NET Files
This week I went nuts over my local IIS. I have never swore to a machine that much in my whole life. ...
- IIS 8.0 Using ASP.NET 3.5 and ASP.NET 4.5微软官方安装指导
from:https://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45 S ...
- [整理]IIS 6.0 下部署 Asp.net MVC Web Api 后 HTTP PUT and DELETE 请求失败
http://guodong.me/?p=1560 ASP.NET MVC 4 has a new feature called WebAPI which makes it much easier t ...
- IIS 7.0 的 ASP.NET 应用程序生命周期概述
文章:IIS 7.0 的 ASP.NET 应用程序生命周期概述 地址:https://msdn.microsoft.com/zh-cn/library/bb470252(v=vs.100).aspx ...
- IIS 5.0 和 6.0 的 ASP.NET 应用程序生命周期概述
本主题概述 ASP.NET 应用程序的生命周期,列出了重要的生命周期事件,并描述了您编写的代码将如何适应于应用程序生命周期.本主题中的信息适用于 IIS 5.0 和 IIS 6.0.有关 IIS 7. ...
随机推荐
- angularJS的核心特性
前几天师傅让我了解一下angularJS,angularJS是一个前端框架,具体的优缺点和运用场景我现在也还没有搞清楚,暂时就先不做描述了,留到运用以后进行补充吧. angularJS四大核心特性:M ...
- 数位DP入门Ural1057
CF一战让我觉得很疲倦,所以今天感觉很慢. 昨天解D题时候,因为太累,根本连题目都没看,今天看了之后感觉不会做,听闻是数位DP问题. 有某神说过,DP的功力建立在刷过的题上,我真的毫无功力可言. 介绍 ...
- 网站开发常用jQuery插件总结(11)折叠插件Akordeon
实现折叠菜单,可以完全不使用插件.如果使用jquery的话,实现起来也比较简单,我们只需要定义折叠菜单的样式,然后使用jquery中的渐隐渐现就可以了.如果我们自己写折叠菜单,可以方便的使用我们自己的 ...
- 纯原生js移动端日期选择插件
最近在项目上需要使用日期选择插件,由于是移动端的项目,对请求资源还是蛮节约的,可是百度上一搜,诶~全是基于jquery.zepto的,本来类库就很大,特别像mobiscroll这种样式文件一大堆又丑又 ...
- IBM总架构师寇文东谈程序员的职业规划
有些年轻的程序员向我咨询,将来的路该怎么走?俗话说,条条大路通罗马.不同的路都能走向成功,到底选择哪条路,取决于自己的兴趣.可能有程序员会问:如果还没有找到自己的兴趣怎么办?我的建议是多尝试,努力做, ...
- bss段为什么需要初始化?
我们都知道bss段需要初始化,但是这是为什么呢? 通过浏览资料,我们都会发现,bss段是不会出现在程序下载文件(*.bin *.hex)中的,因为全都是0.如果把它们出现在程序下载文件中,会增加程序下 ...
- (转)搜索Maven仓库 获取 groupid artifactId
转载自:http://blog.csdn.net/z69183787/article/details/22188561 使用Maven进行开发的时候,比较常见的一个问题就是如何寻找我要的依赖,比如说, ...
- 【转】ant命令总结
http://feiyeguohai.iteye.com/blog/1295922 ant命令总结 1 Ant是什么? Apache Ant 是一个基于 Java的生成工具. 生成工具在软件开发中用 ...
- 浅谈JavaScript的push()函数
push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度.返回值是把指定的值添加到数组后的新长度. 语法:arrayObject.push(newelement1,newelement2,. ...
- underscore
http://www.byywee.com/page/M0/S819/819654.html http://www.haogongju.net/art/1127253 http://hi.baidu. ...