注册HttpHandler
How to: Register HTTP Handlers
After you have created a custom HTTP handler class, you must register it in the Web.config file. This enables ASP.NET to call the HTTP handler in order to service requests for resources that have the specified file name extension.
How you register an HTTP handler depends on the version of Internet Information Services (IIS) that hosts your application. For IIS 6.0, you register the handler by using the httpHandlers section of the Web.config file. For IIS 7.0 running in Classic mode, you register the handler in the httpHandlerssection, and you map the handler to the Aspnet_isapi.dll file. For IIS 7.0 running in Integrated mode, you register the handler by using the handlerselement in the system.WebServer section.
To register an HTTP handler for IIS 6.0
Compile the HTTP handler class and copy the resulting assembly to the Bin folder under the application's root folder.
-or-
Put the source code for the handler into the application's App_Code folder.
For an example of an HTTP handler, see Walkthrough: Creating a Synchronous HTTP Handler.
In the application's Web.config file, create an httpHandlers section.
The following example shows how to register an HTTP handler that responds to requests for the SampleHandler.new resource. The handler is defined as the class SampleHandler in the assembly SampleHandlerAssembly.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly" />
</httpHandlers>
</system.web>
</configuration>The following example maps all HTTP requests for files that have the file name extension ".SampleFileExtension" to the SampleHandler2 class. In this case, the handler code is in the App_Code folder, so you do not have to specify an assembly.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.SampleFileExtension"
type="SampleHandler2 " />
</httpHandlers>
</system.web>
</configuration>Configure IIS to forward the request for the custom file name extension to ASP.NET.
For more information, see How to: Configure an HTTP Handler Extension in IIS.
To register an HTTP handler for IIS 7.0 running in Classic mode
Compile the HTTP handler class and copy the resulting assembly to the Bin folder under the application's root folder.
-or-
Put the source code for the handler into the application's App_Code folder.
For an example of an HTTP handler, see Walkthrough: Creating a Synchronous HTTP Handler.
In the application's Web.config file, create an httpHandlers section.
Create a system.webServer section inside the configuration element.
Create a handlers element inside the system.WebServer section.
NoteYou must define both an httpHandlers element and a handlers element.
The following example shows how to register an HTTP handler that responds to requests for the SampleHandler.new resource. The handler is defined as the class SampleHandler in the assembly SampleHandlerAssembly.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="TestLip" path="*.lip" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
</handlers>
</system.webServer>
</configuration>Replace FrameworkPath with the correct path to the Aspnet_isapi.dll file.
The following example maps all HTTP requests for files that have the file name extension ".SampleFileExtension" to the SampleHandler2 class. In this case, the handler code is in the App_Code folder, so you do not have to specify an assembly.
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.SampleFileExtension"
type="SampleHandler2" />
</httpHandlers>
<system.web>
<system.webServer>
<handlers>
<add name="TestLip" path="*.lip" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness64" />
</handlers></system.webServer> </configuration>
Replace FrameworkPath with the correct path to the Aspnet_isapi.dll file.
NoteFor IIS 7.0 running in Classic mode, you do not have to separately use IIS Manager to map the file name extension to the Aspnet_isapi.dll file, as you do with IIS 6.0. You can map the extension in the Web.config file.
To register an HTTP handler for IIS 7.0 running in Integrated Mode
Compile the HTTP handler class and copy the resulting assembly to the Bin folder under the application's root folder.
-or-
Put the source code for the handler into the application's App_Code folder.
For an example of an HTTP handler, see Walkthrough: Creating a Synchronous HTTP Handler.
In the application's Web.config file, create a handlers element in the system.webServer section.
NoteHandlers that are defined in the httpHandlers element are not used. If you do not remove the httpHandlers registrations, you must set the validation element’s validateIntegratedModeConfiguration attribute to false in order to avoid errors. The validation element is a child element of the system.webServer element. For more information, see "Disabling the migration error message" in ASP.NET Integration with IIS 7.0.
The following example shows how to register an HTTP handler that responds to requests for the SampleHandler.new resource. The handler is defined as the class SampleHandler in the assembly SampleHandlerAssembly.
<configuration>
<system.webServer>
<handlers>
<add name="SampleHandler" verb="*"
path="SampleHandler.new"
type="SampleHandler, SampleHandlerAssembly"
resourceType="Unspecified" />
</handlers>
</system.webServer>
</configuration>
NoteThe resourceType attribute performs the same function as the Verify file exists option in IIS manager for IIS 6.0.
The following example shows how to map all HTTP requests to files with the file name extension ".SampleFileExtension" to the SampleHandler2HTTP handler class. In this case, the handler code is in the App_Code folder, so you do not have to specify an assembly.
<configuration>
<system.webServer>
<handlers>
<add name="SampleHandler2" verb="*"
path="*.SampleFileExtension"
type="SampleHandler2" />
resourceType="Unspecified" />
<handlers>
</system.webServer>
</configuration>For IIS 7.0 running in Integrated mode, only the registration in the handlers element is required.
For more information about the IIS web.webServer configuration element, see system.webServer Section Group (IIS Settings Schema) on the MSDN Web site.
For more information about how to configure a handler for a custom file name extension, see How to: Configure an HTTP Handler Extension in IIS.
注册HttpHandler的更多相关文章
- webconfig中注册HttpHandler报错:检测到在集成的托管管道模式下不适用的 ASP.NET 设置。
为什么会出现以上错误? 在IIS7的应用程序池有两种模式,一种是"集成模式",一种是"经典模式". 经典模式 则是我们以前习惯的IIS 6 的方式. 如果使用集 ...
- (转)HttpHandler与HttpModule的理解与应用
神秘的HttpHandler与HttpModule 大学时候我是从拖控件开始学习 asp.net的,对.net的很多类库对象都不是很了解.所以看到大家写一些个性的asp.net名词,就感觉asp.ne ...
- HttpHandler与HttpModule介绍
前言:作为一个开发人员,我们看过很多的关于开发的书,但是都是教我们"知其然",并没有教我们"知其所以然",我们开发web项目的过程中,当我们输完URL敲下回车就 ...
- ASP.NET页面生存周期
.Net的Page请求过程:
- FastRPC 3.2 发布,高性能 C++ 协程 RPC 框架
用过go erlang gevent的亲们应该都会知道协程在应用中带来的方便. 如果对协程不理解的同学,通过阅读下面例子可以快速了解我们框架的协程的意义,已了解的可以跳过这部分. 协程例子:假设我们要 ...
- ASP.NET管道模型简析
我相信在第一次听到这个名词时,有的小伙伴会一脸懵,而且还有很多疑问,其实我在第一次接触这个概念时跟很多小伙伴一样一脸懵. 接下来我将以我自己的理解来讲述什么是管道模型. 什么是管道模型 首先有没有小伙 ...
- ASP.NET Core的路由[1]:注册URL模式与HttpHandler的映射关系
ASP.NET Core的路由是通过一个类型为RouterMiddleware的中间件来实现的.如果我们将最终处理HTTP请求的组件称为HttpHandler,那么RouterMiddleware中间 ...
- 注册URL模式与HttpHandler的映射关系
注册URL模式与HttpHandler的映射关系 ASP.NET Core的路由是通过一个类型为RouterMiddleware的中间件来实现的.如果我们将最终处理HTTP请求的组件称为HttpHan ...
- httphandler和httpmodule的区别
ASP.Net处理Http Request时,使用Pipeline(管道)方式,由各个HttpModule对请求进行处理,然后到达 HttpHandler,HttpHandler处理完之后,仍经过Pi ...
随机推荐
- Codeforces 731B Coupons and Discounts(贪心)
题目链接 Coupons and Discounts 逐步贪心即可. 若当前位为奇数则当前位的下一位减一,否则不动. #include <bits/stdc++.h> using name ...
- RAID 1-6
RAID 0 RAID 0亦称为带区集.它将两个以上的磁盘串联起来,成为一个大容量的磁盘.在存放数据时,分段后分散存储在这些磁盘中,因为读写时都可以并行处理,所以在所有的级别中,RAID 0的速度是最 ...
- google搜索打不开?提供 国内几个给力的服务器
http://203.208.46.145/ 这是北京的机器,快到飞起来. http://74.125.224.232/, 屡试不爽 用编辑器打开C:\WINDOWS\system32\drivers ...
- java visual VM使用简介
转载请注明出处 http://blog.csdn.net/pony_maggie/article/details/44999175 作者:小马 VisualVM 是一款免费的性能分析工具.它通过 jv ...
- EasyMvc入门教程-基本控件说明(3)时间线
我们有时候经常看到如下的页面: 或者快递物流信息图标,那么利用EasyMvc如何实现呢?很简单,看下面的例子: @{ var data=new List<TimeLineItem>() { ...
- TensorFlow笔记四:从生成和保存模型 -> 调用使用模型
TensorFlow常用的示例一般都是生成模型和测试模型写在一起,每次更换测试数据都要重新训练,过于麻烦, 以下采用先生成并保存本地模型,然后后续程序调用测试. 示例一:线性回归预测 make.py ...
- 2016.7.12 eclipse和IDEA中mybatis generator插件的安装与使用
Eclipse中的安装 http://jingyan.baidu.com/article/9faa7231506ed8473c28cbee.html 1.下载插件 2.将插件generator的fea ...
- [Redis]windows下redis的安装和启动
官方的下载地址是: http://redis.io/download 在win64一栏中能够看到redis原本是没有windows版本号的,windows版本号是Microsoft Open Tech ...
- es6 - 箭头
class User { constructor(name, age) { this.name = name; this.age = age; } changeName(name) { this.na ...
- php hex2bin 物联网设备发送十六进制数据
hex2bin("十六进制字符") 折腾了三天 后来大神一句话搞定 : hex2bin("十六进制字符") 网上有个方向是错误的 就是 "\xAA\x ...