locked
using handlers for images RRS feed

  • Question

  • User-192715767 posted

    I have configured my IIS website to use my Imagehandler application and it works fine if the image being requested exists on the website. (by example http://www.worldtechmission.com/Images/logo2.jpg)

    However, if the image does not exist (http://www.worldtechmission.com/Images/logo23.jpg) the handler does not fire. The goal of the handler is to intercept the image file and determine if it exists. If it does not, it will return a 'dummy' image.

    The question I guess is the order of events. Does IIS check to see if the location exists on the site then if it exists, it executes the handler? If this is so, is there a way around this?

    The secondary use of this will be to use the image file to 'track' emails received. Originally we were going to use something like <img src="....ashx?id=1234"..../> where the ashx would point to the handler which would return the correct image for the ID value passed and record the ID to the database. The concern with this approach would be that the email's could be opened after a handler's name change.

    Thank you in advance.

    Wednesday, July 18, 2007 4:13 PM

Answers

  • User-2110929815 posted

    Run IIS Manager
    Find necessary website
    Select "Properties" from context menu
    On Virtual Directory tab click Configuration button
    On Mapping tab click Add button

    Then enter following data:
    Executable: C:\WINDOWS\Microsoft.NET\Framework\...\aspnet_isapi.dll, where ... is framework version.
    Extension: .jpg
    Verbs/Limit to: GET
    Uncheck combobox "Check that file exists".
    Press OK.

    It has to work.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 19, 2007 7:49 AM

All replies

  • User1825434375 posted

    IIS might have higher priority to handle this. I see two ways of get around this:

    1. Unsubscribe from .jpg handling. Create common custom handler for all images, e.g. http://www.worldtechmission.com/Image.ashx?img=Images/logo2.jpg
    2. Create a 404 error handler. Configure IIS so that 404 error is getting handled by your own 404error.ashx. Inside 404error.ashx use QueryString[0] to gain the url that caused the 404 error and see if it has .jpg extension. If so - output dummy image content, otherwise redirect to real 404 error page.
    Thursday, July 19, 2007 4:09 AM
  • User-2110929815 posted

    Run IIS Manager
    Find necessary website
    Select "Properties" from context menu
    On Virtual Directory tab click Configuration button
    On Mapping tab click Add button

    Then enter following data:
    Executable: C:\WINDOWS\Microsoft.NET\Framework\...\aspnet_isapi.dll, where ... is framework version.
    Extension: .jpg
    Verbs/Limit to: GET
    Uncheck combobox "Check that file exists".
    Press OK.

    It has to work.
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, July 19, 2007 7:49 AM