日期:2014-05-20 浏览次数:21099 次
<%@ WebHandler Language="C#" Class="Echo" %> using System; using System.Web; using System.IO; public class Echo : IHttpHandler { private System.Text.Encoding DefaultEncoding = System.Text.Encoding.UTF8; public void ProcessRequest (HttpContext context) { context.Response.ContentType = "text/plain"; context.Response.ContentEncoding = DefaultEncoding; Stream inputStream = context.Request.InputStream; using (StreamReader reader = new StreamReader(inputStream, DefaultEncoding)) { string requestContent = reader.ReadToEnd(); string responseContent = string.Format("Received: {0} <== END", requestContent); context.Response.Write(responseContent); } } public bool IsReusable { get { return false; } } }