<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
/// <summary>
/// 一般处理程序就是一个类,这个类就是我们自己编写的一段服务器代码,用来处理特定的用户请求
/// </summary>
public class Handler : IHttpHandler {
// HttpApplication对象的ProcessRequest(HttpContext context)方法是Asp.net应用程序生命周期的开始,
// 而页面的ProcessRequest(HttpContext context)方法,则是页面生命周期的开始。页面生命周期主要指的
// 是WebForm,对于一般处理程序来说就是一个简单的ProcessRequest()方法
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
//context.Response.Write("Hello World");
System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
sbHtml.Append("<html><head><title>第一个一般处理程序</title></head><body><h1>" + DateTime.Now.ToString("yyyy-mm-dd hh:mm:ss") + "</h1></body></html>");
context.Response.Write(sbHtml.ToString());
}
public bool IsReusable {
get {
return false;
}
}
}