从HttpContext在Web.Config中获取已注册的HttpHandlers

时间:2011-08-16 19:32:50

标签: asp.net

有没有办法从当前IHttpHandler或web.config获取已注册HttpContext的类型?

我正在尝试查看我的HttpHandler是否已在WebControl的web.config中注册。

1 个答案:

答案 0 :(得分:5)

您可以通过以下方式从web.config获取已注册HttpHandler的列表:

using System.Configuration;
using System.Web.Configuration;

Configuration cfg = WebConfigurationManager.OpenWebConfiguration("/");
HttpHandlersSection hdlrs = (HttpHandlersSection)cfg.GetSection("system.web/httpHandlers");