MSDN中,有篇文章《在 ASP.NET 中使用 HTTPHandler 实现 Front Controller》,标题中的HTTPHandler指的是什么?
解决方案 »
- 如何实现淘宝的 “你可能还喜欢” 功能?
- 帮忙啊!索引(从零开始)必须大于或等于零,且小于参数列表的大小
- 带有[Serializable]的实体类是怎么回事?
- 索引 搜索
- 新手问题,查看代码
- 可以自己写代码给ActiveX控件签名吗?签名后IE是否不再提示提示“在此页上的ActiveX控件和本页上的其它部份的交互可能不安全。你想允许这
- 如何取服务器的真实ip(0.0.0.0)地址/我晕了/没分了
- 请教一个Dropdownlist的问题
- ASP.NET MVC分页组件MvcPager 2.0版发布暨网站全新改版
- @DateTime.Now.ToString("M") 我不要前导 零,怎么日期也出来了
- 求教:页面跳转及传值。。
- 更新DATASET语法错误
Method Name Description
ProcessRequest Used o call Http Requests.
IsReusable To check the reusability of same instance handler with a new request of same type. Configuring HTTP Handlers
The <httpHandlers> configuration section handler is responsible for mapping incoming URLs to the IHttpHandler or IHttpHandlerFactory class. It can be declared at the computer, site, or application level. Subdirectories inherit these settings.Administrators use the <add> tag directive to configure the <httpHandlers> section. <Add> directives are interpreted and processed in a top-down sequential order. Use the following syntax for the <httpHandler> section handler:<httpHandlers>
<add verb="[verb list]" path="[path/wildcard]" type="[COM+ Class], [Assembly]" validate="[true/false]" />
<remove verb="[verb list]" path="[path/wildcard]" />
<clear />
</httpHandlers> Creating HTTP Handlers
To create an HTTP handler, you must implement the IHttpHandler interface. The IHttpHandler interface has one method and one property with the following signatures:
void ProcessRequest(HttpContext);
bool IsReusable {get;}Customized Http HandlerBy customizing http handlers, new functionalities can be added to Web Server. Files with new extensions like .text for a text file can be handled by Web Server by using http handlers. The future of customization can lead to hosting .jsp pages in IIS by finding adequate ISAPI extensions. The following steps are involved to create customized http handler:
1. Create a C# class library as 揈xamplehandler?br> 2. Name class as 揌andlerclass.cs?/font>using System;
using System.Web;
using System.Web.SessionState;
namespace ExampleHandler
{
/// <summary>
/// Summary description for Examplehandler.
/// </summary>
public class Handlerclass : IHttpHandler
{
public Handlerclass()
{
//
// TODO: Add constructor logic here
//
}#region Implementation of IHttpHandler
public void ProcessRequest(System.Web.HttpContext context)
{
HttpResponse objResponse = context.Response ;
HttpSessionState objSession = context.Session ;
objResponse.Write("<html><body><h1>Hello World from Handler") ;
objResponse.Write("</body></html>") ;
}public bool IsReusable
{
get
{
return true;
}
}
#endregion
}
} Compile it and place it in the bin directory of TestApp project.
HttpHandler :HttpHandler 是实现 IHttpHandler 或 IHttpAsyncHandler 接口的类;分为同步 HttpHandler和异步 HttpHandler。同步 HttpHandler 实现 System.Web.IHttpHandler 接口;异步 HttpHandler 实现 System.Web.IHttpAsyncHandler 接口。