简述HttpHander,应用,简单源码,配置信息!
看了,我认为值得的,在追加10到100不等分数!~
可以用任何符合公共语言规范 (CLS) 的语言编写自定义 HTTP 处理程序来处理特定的、预定义类型的 HTTP 请求。响应这些特定请求的是在 HttpHandler 类中定义的可执行代码,而不是常规的 ASP 或 ASP.NET网页。HTTP
处理程序向您提供一种方法,使您可以与 IIS Web 服务器的低级别的请求和响应服务交互,同时提供极其类似于 ISAPI 扩展但编程模型较为简单的功能
using System.Web;namespace Ysoho{
public class HelloWorldHandler : IHttpHandler
{
public HelloWorldHandler()
{
}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
// This handler is called whenever a file ending
// in .sample is requested. A file with that extension
// does not need to exist.
Response.Write("<html>");
Response.Write("<body>");
Response.Write("<h1>Hello from a synchronous custom HTTP handler.</h1>");
Response.Write("</body>");
Response.Write("</html>");
}
public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}}<configuration> <system.web> <httpHandlers> <add verb="*" path="1.aspx" type="HelloWorldHandler , Ysoho.HelloWorldHandler " /> </httpHandlers> <system.web></configuration>
上面代码 当访问 1.aspx时 会运行 这个 HelloWorldHandler页面中直接 输出Hello from a synchronous custom HTTP handler