现在的位置: 首页 > 综合 > 正文

一般处理程序一 HelloWorld

2013年08月23日 ⁄ 综合 ⁄ 共 503字 ⁄ 字号 评论关闭
<%@ 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属性里面。

 

 

 

 

 

 

抱歉!评论已关闭.