asp.net ImageResizer InterceptModule possibly blocking httphandler?

294 views Asked by At

We currently have the ImageResizer module running on our server and everything is working just fine. We are now attempting to get the watermark plugin to work in conjunction with this module, however, we do not want to use this plugin via a QS parameter. We've added http Handlers to process all image requests. For any external requests (URL referrer is nothing), we are adding the QS to the setting to the image builder and pushing out the new image. This is working as intended.

We have the watermark plugin working as intended and and the watermark is correctly showing up for external request requests. However, the http Handler is not be triggered if the request has an ImageResize QS attached to it (as all our product images currently do).

So domain.dev/images/03125_Purge_2L.jpg gets caught by the handler but domain.dev/images/03125_Purge_2L.jpg?format=jpg&scale=both&mode=pad&anchor=middlecenter&width=300&height=300 does not (it is still being processed thru the InterceptModule)

The request is either being intercepted by the ImageResizer InterceptModule or triggering the Handler, but not both. I've looked thru the InterceptModule code but nothing indicated, as far as I can see, that it should be preventing the http handler from being triggered later on down the pipeline.

I honestly cannot say for sure if it is a matter of something from within the InterceptModule or my config set up for the HttpHandlers.

Someone somewhere out there must have done this same thing...

Current config setting:

<modules>
        <remove name="ImageResizingModule" />
        <add name="ImageResizingModule"
             type="ImageResizer.InterceptModule" />
    </modules>
<handlers>
        <remove name="InyoWatermarkHandler-jpg" />
        <add name="InyoWatermarkHandler-jpg"
                path="*.jpg"
                verb="GET"
                type="Domain.Images.WatermarkHandler, Domain.Images" />
        <remove name="InyoWatermarkHandler-png" />
        <add name="InyoWatermarkHandler-png"
                path="*.png"
                verb="GET"
                type="Domain.Images.WatermarkHandler, Domain.Images" />
        <remove name="InyoWatermarkHandler-gif" />
        <add name="InyoWatermarkHandler-gif"
                path="*.gif"
                verb="GET"
                type="Domain.Images.WatermarkHandler, Domain.Images" />
        <remove name="InyoWatermarkhandler-bmp" />
        <add name="InyoWatermarkhandler-bmp"
                path="*.bmp"
                verb="GET"
                type="Domain.Images.WatermarkHandler, Domain.Images" />
    </handlers>

Since both the ImageResizer.InterceptModule and the http Handlers work independently, I am making a certain assumption that the setup is correct to some degree.

1

There are 1 answers

0
Lilith River On BEST ANSWER

It appears that you're trying to replace the HttpModule with your own handler instead of using the provided hooks to implement this properly. We have a best practices guide which explains why this is so important.

You should replace your HttpHandler with an event handler for Config.Current.Pipeline.PostRewrite. This will allow you to enfore watermarking either based on the referrer or any other criteria you wish to use. We have an example of doing this based on folder name.

TL;DR: Never use an HttpHandler for asset delivery, they're fundamentally flawed.