<%@ 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;
}
}
}
统一接口调用
最新推荐文章于 2024-05-06 10:31:11 发布