62,074
社区成员
发帖
与我相关
我的任务
分享
static Default()
自己修改一下。
在这里,应该注册百八十个 IHttpHandler 命令处理程序,也就是处理 method 参数的程序。<%@ WebHandler Language="C#" Class="Default" %>
using System;
using System.Web;
using System.Collections.Generic;
public class Default: IHttpHandler
{
private static Dictionary<string, IHttpHandler> dic = new Dictionary<string, IHttpHandler>();
static TestCommand()
{
dic.Add("user.get", new GetUser());
}
public void ProcessRequest(HttpContext context)
{
var cmd = context.Request.QueryString["method"];
IHttpHandler handler;
if (!dic.TryGetValue(cmd, out handler))
{
context.Response.StatusCode = 404;
return;
}
if (!handler.IsReusable)
handler = (IHttpHandler)Activator.CreateInstance(handler.GetType());
handler.ProcessRequest(context);
}
public bool IsReusable
{
get
{
return false;
}
}
}