我有一个从 msdn 获得的 httphandler,看起来像这样
using System.Web;
public class HelloWorldHandler : IHttpHandler
{
public HelloWorldHandler()
{
}
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
// This handler is called whenever a file ending
// in .sample is requested. A file with that extension
// does not need to exist.
Response.Write("hello");
}
public bool IsReusable
{
// To enable pooling, return true here.
// This keeps the handler in memory.
get { return false; }
}
}
所以我Handler.dll
将它编译并放入C:\inetpub\wwwroot\Handler
然后我添加了这个 Web.config 文件
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.abc"
type="HelloWorldHandler", "HelloWorldHandler" />
</httpHandlers>
</system.web>
</configuration>
并把它C:\inetpub\wwwroot\Handler
也放进去
我想用这个然后我可以去http://localhost/Handler/page.abc
处理程序会拦截请求,但这不是这样吗?我怀疑它可能是 .config 文件?请帮忙。