在Web.Config中找不到HttpHandlerSection [英] HttpHandlerSection not found in Web.Config
问题描述
我有一个旧的WebControl,需要更新才能使用IIS 7.5。
在控件中有一些代码可以检查Handler是否已注册Web.Config。
它使用
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;
在IIS 6上正常工作。但是在IIS 7和转发处理器部分已从< system.web>< httpHandlers> $移出c $ c>到
< system.webServer>< handlers>
将代码更改为
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;
不起作用,handlersection为null 。
那么,我做错了什么?
我已经摆弄了一下它将其更改为
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;
给我一个InvalidCastException。 无法将'System.Configuration.IgnoreSection'类型的对象强制转换为'System.Web.Configuration.HttpHandlersSection'。
gives me an InvalidCastException. "Unable to cast object of type 'System.Configuration.IgnoreSection' to type 'System.Web.Configuration.HttpHandlersSection'."
推荐答案
这篇关于在Web.Config中找不到HttpHandlerSection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!