<%@ WebHandler Language="C#" Class="HelloWorld" %>
using System;
using System.Web;
public class HelloWorld : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}
public bool IsReusable {
get {
return false;
}
}
}
1.1请求响应的过程
1.2一般处理程序详解
①任何一个实现了IHttpHandler接口的类都可以作为外部请求的目标程序。
②contextType:设置相应报文,告诉浏览器以什么方式解析;设置服务器向浏览器发出的相应报文的ContentType属性,浏览器根据此属性内容使用不通的方式来处理相应报文体。
③HttpContext contex:请求的上下文,Contex里面包含了使用的信息和向客户端发送数据的方法,方法都放在response属性里面。