Wednesday, June 12, 2013

Registering an HTTP Handler in Web.Config (and generate automatic thumbnails)


Problem:
Adding an HTTP Handler causes a 500 Server Error

Solution:
Register the handler correctly in Web.Config:
- The type should be {Class}, {AssemblyName}
- For IIS7, Use system.webServer, handlers section instead of system.web, httpHandlers

IIS7
<system.webServer>
    <handlers>
      <add verb="*" name="imageHandler" path="ImageThumbnailer.ashx" type="Shp.Handler.Thumbnailer, Shp.Handler"/>
    </handlers>
</system.webServer>

IIS6
  <system.web>
    <httpHandlers>
      <add verb="*" path="ImageThumbnailer.ashx" type="Shp.Handler.Thumbnailer, Shp.Handler"/>
    </httpHandlers>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>

Helper Source:
http://stackoverflow.com/questions/2858738/problem-mapping-httphandler-http-error-404-not-found

Generate Thumbnails automatically with an HTTP Handler:
http://www.codeproject.com/Articles/16120/Thumbnailer-HTTP-Handler

No comments:

Post a Comment