Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set a handler in web.config with IIS7?

Tags:

asp.net

I have a handler, on runtime it create a watermark on images from a specific folder. The problem is that it worked, but now it doesn't.

All that I did was to changed the hosting.

My web.config looks like this:

<handler>
 <add verb="*" name="ImageWatermarkHandler" type="ImageWatermarkHandler" 
      path="Pics/*.jpg,Pics/*.png"  modules="IsapiModule"
      scriptProcessor="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll" 
      resourceType="Unspecified" preCondition="integratedMode" />
</handler>

Can you please help me?

like image 230
Coderock.net Avatar asked Jan 07 '12 12:01

Coderock.net


2 Answers

Under IIS 7, you have to specify custom http handlers and modules under the configuration/system.webServer/handlers element of your web.config (unlike older IIS versions, where the element is configuration/system.web/httpHandlers).

There's difference between integrated mode (you only need the handlers part) and classic mode(you need both handlers and httpHandlers). For details see the MSDN entry

Edit: At first I haven't noticed the precondition for integrated mode, could it be that the new hosting runs your app in classic mode?

like image 145
voidengine Avatar answered Oct 17 '22 14:10

voidengine


your config file should look like this,

<configuration>
  <system.web>
    <httpHandlers>
      <add verb="*" path="Pics/*.jpg,Pics/*.png" type="ImageWatermarkHandler"/>
    </httpHandlers>
  </system.web>
  <system.webServer>
    <handlers>
      <add verb="*" path="Pics/*.jpg,Pics/*.png" name="ImageWatermarkHandler" type="ImageWatermarkHandler"/>
    </handlers>
    <validation validateIntegratedModeConfiguration="false"/>
  </system.webServer>
</configuration>

for more information, http://msdn.microsoft.com/en-us/library/bb515343.aspx

like image 25
Chamika Sandamal Avatar answered Oct 17 '22 14:10

Chamika Sandamal