有没有办法从当前IHttpHandler
或web.config获取已注册HttpContext
的类型?
我正在尝试查看我的HttpHandler
是否已在WebControl
的web.config中注册。
答案 0 :(得分:5)
您可以通过以下方式从web.config获取已注册HttpHandler
的列表:
using System.Configuration;
using System.Web.Configuration;
Configuration cfg = WebConfigurationManager.OpenWebConfiguration("/");
HttpHandlersSection hdlrs = (HttpHandlersSection)cfg.GetSection("system.web/httpHandlers");