如何获取到默认的ASP.NET页面的处理程序或Web服务处理器的参考? [英] How to obtain a reference to the default ASP.NET page handler or web-services handler?
问题描述
考虑包含以下 HttpHandlers的
声明中的的Web.config
文件:
Consider a Web.config
file containing the following httpHandlers
declaration:
<httpHandlers>
<add verb="*" path="*" type="MyWebApp.TotalHandlerFactory"/>
</httpHandlers>
在换句话说,此处理厂要看到所有的请求,使其得到一个机会来处理它们。然而,它并不一定要真正处理所有的人,只有那些符合一定的运行时间条件:
In other words, this handler factory wants to "see" all incoming requests so that it gets a chance to handle them. However, it does not necessarily want to actually handle all of them, only those that fulfill a certain run-time condition:
public sealed class TotalHandlerFactory : IHttpHandlerFactory
{
public IHttpHandler GetHandler(HttpContext context, string requestType, string url, string pathTranslated)
{
if (some condition is true)
return new MySpecialHttpHandler();
return null;
}
public void ReleaseHandler(IHttpHandler handler) { }
}
但是,这样做像这样完全覆盖默认ASP.NET处理程序,这意味着ASP.NET页面和网络服务不再起作用。我只是得到了一个空白页面,不履行其在如果的一定条件每个URL。因此,似乎返回空
是错误的做法。
所以,我需要做什么,而不是返回,使ASP.NET页面和网络服务仍正常处理?
So what do I need to return instead so that ASP.NET pages and web services are still handled normally?
推荐答案
这是不可能做到这一点的一般情况。
It is not possible to do this in the general case.
这篇关于如何获取到默认的ASP.NET页面的处理程序或Web服务处理器的参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!