谁能帮我解释一下IHttpHandler类的功能及一些方法!
谁能帮我解释一下IHttpHandler类的功能及一些方法!
以下的其的一些应用,我不太明白!
public class MyFactory : IHttpHandlerFactory
{
//virtual 关键字用于修改方法或属性的声明,在这种情况下,方法或属性被称作虚拟成员。
//IHttpHandler 定义 ASP.NET 为使用自定义 HTTP 处理程序同步处理 HTTP Web 请求而实现的协定。
//HttpContext 封装有关个别 HTTP 请求的所有 HTTP 特定的信息。
//virtual 方法就是将基类中的方法进行重写!
public virtual IHttpHandler GetHandler(HttpContext context,
string requestType,
string url,
string pathTranslated)
{
string fname = url.Substring(url.LastIndexOf('/')+1);
string cname = fname.Substring(0, fname.IndexOf('.'));
string className = "test." + cname;
Object h = null;
// Try to create the handler object.
try
{
// Create the handler by calling class abc or class xyz.
//Activator 包含特定的方法,用以在本地或从远程创建对象类型,或获取对现有远程对象的引用。
//Activator.CreateInstance 使用与指定参数匹配程度最高的构造函数创建指定类型的实例。
h = Activator.CreateInstance(Type.GetType(className));
}
catch(Exception e)
{
throw new HttpException("Factory couldn't create instance " +
"of type " + className, e);
}
return (IHttpHandler)h;
}
// This is a must override method.
public virtual void ReleaseHandler(IHttpHandler handler)
{
}
}
问题点数:20、回复次数:1Top
1 楼zfwdf(山水)回复于 2004-09-02 10:57:44 得分 20
upTop




