I have an old WebControl that needs to be updated to work with IIS 7.5.
In the control there is some code that checks if the Handler is registered in the Web.Config.
It opens the HandlerSection using
System.Web.Configuration.HttpHandlersSection handlerSection = System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.web/httpHandlers") as System.Web.Configuration.HttpHandlersSection;
which works fine on IIS 6. But on IIS 7 and forward the Handler Section has been moved from
<system.web><httpHandlers>
to
<system.webServer><handlers>
Changing the code to
System.Web.Configuration.HttpHandlersSection handlerSection = System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.webServer/handlers") as HttpHandlersSection;
doesn't work, handlersection is null.
So, what am I doing wrong?
I've fiddled with it a bit and changing it to just
System.Web.Configuration.HttpHandlersSection handlerSection = System.Web.Configuration.WebConfigurationManager.GetWebApplicationSection("system.webServer") as System.Web.Configuration.HttpHandlersSection;
gives me an InvalidCastException. "Unable to cast object of type 'System.Configuration.IgnoreSection' to type 'System.Web.Configuration.HttpHandlersSection'."