Search code examples
c#iishttphandler

HttpHandlers fire for some paths but not all


I am trying to figure out why certain paths work and others do not for the same httphandler. I am on IIS10.

My handler looks like this:

<add name="IconStore" preCondition="integratedMode" path="icons/*" verb="*" type="SomePath.Controls.IconStoreHandler, SomePath.Controls"/>

And this handler will fire for this path:

<img class="tip" data-tip="redacted" src="icons/interface-question-mark">

Which gets added here:

<asp:Image runat="server" CssClass="tip" data-tip="<%$ Resources:Resources, Redacted%>" ImageUrl="icons/interface-question-mark" />

but will not fire for this implementation:

<div class="redacted" initialized="true" title="" style="background-image: url("icons/interface-question-mark");"></div>

Something to note, when I copy the element that is not working from chrome's inspector, the double quotes are &quot; but I did some research and doesn't seem to be an issue.

Why does the first implementation fire, but the second one does not? If I use a different handler path, like:

      <add name="Icon.axd" preCondition="integratedMode" path="Icon.axd" verb="GET" type="SomePath.Controls.IconStoreHandler, SomePath.Controls"/>

And then my implementation is something like:

<div class="redacted" initialized="true" title="" style="background-image: url("Icon.axd?name=test");"></div>

The handler will fire for both implementations.


Solution

  • So it turns out the above does work, and I had a re-write rule set up that was redirecting those requests to http://localhost:80/redacted/user?site=icons

    I added an Anti-re-write path for icons and it now works.

    E: Anti-rewrite path looks like:

    <add input="{URL}" pattern="^/[\w-]+/icons/*" negate="true" />
    

    in rewriteRules.config