Friday 12 March 2010

Help! My HTTP Handler doesn't work in IIS7!

I faced this problem earlier today. Thankfully (as is usually the case) it was simple to resolve.

If you face this problem with an httphandler (usually .axd extension), make sure you have added a new "system.webServer" section to your web.config file. Yes, that's right, IIS7 doesn't look at the old httpHandlers and httpModules conig sections in system.web. You will need to copy your these sections into the new system.webServer section.

But wait, there's more! What caught me out today was the fact that IIS7 needs to see a name attribute in each "add" element. I am using a third party captcha on one of my sites - Lanap Botdetect. After puzzling over a 500.19 server error about incorrect configuration, I realised that IIS7 was expecting to see a name attribute, so I simply added name="LanapCaptcha" to the element (see below). Problem solved. I you have any specific questions related to httphandler problems, post them in the comments section below and I'll try and help you. If this post helped you, please Digg it using the Digg button at the top!

</system.webServer>

...

<handlers>

<remove name="WebServiceHandlerFactory-Integrated"/>

<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

<add name="LanapCaptcha" path="LanapCaptcha.aspx" verb="*" type="Lanap.BotDetect.CaptchaHandler, Lanap.BotDetect" />

<add name="ASBXHandler" verb="GET,HEAD,POST" path="*.asbx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</handlers>

</system.webServer>

No comments: