I have a special folder in the Sitecore media library (v9.1.1)
that I would like to run a custom MediaRequestHandler
on. The path to the folder is /media library/files/securefiles
.
I read this post (https://sitecoreblog.patelyogesh.in/2013/09/sitecore-custom-http-handlers.html) that made it seem like I could create a custom handler and use the Trigger to specify the prefix for the handler. But it doesn't seem to be working. Here is what I currently have:
In web.config
<configuration>
<system.webServer>
<handlers>
<add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" name="Sitecore.MediaRequestHandler" />
<add verb="*" path="sitecore_media_secure1.ashx" type="MyCustomMediaRequestHandler, MyCustomAssembly" name="MyCustomMediaRequestHandler" />
</handlers>
</system.webServer>
</configuration>
And in Sitecore.Config
<sitecore>
<mediaLibrary>
<mediaPrefixes>
<prefix value="-/media/files/securefiles" />
</mediaPrefixes>
</mediaLibrary>
<customHandlers>
<handler trigger="-/media/" handler="sitecore_media.ashx" />
<handler trigger="~/media/" handler="sitecore_media.ashx" />
<handler trigger="~/api/" handler="sitecore_api.ashx" />
<handler trigger="-/api/" handler="sitecore_api.ashx" />
<handler trigger="-/xaml/" handler="sitecore_xaml.ashx" />
<handler trigger="~/xaml/" handler="sitecore_xaml.ashx" />
<handler trigger="-/icon/" handler="sitecore_icon.ashx" />
<handler trigger="~/icon/" handler="sitecore_icon.ashx" />
<handler trigger="-/temp/" handler="sitecore_temp.ashx" />
<handler trigger="~/temp/" handler="sitecore_temp.ashx" />
<handler trigger="~/feed/" handler="sitecore_feed.ashx" />
<handler trigger="-/feed/" handler="sitecore_feed.ashx" />
<handler trigger="-/media/files/securefiles/" handler="sitecore_media_secure1.ashx" />
<handler trigger="~/media/files/securefiles/" handler="sitecore_media_secure1.ashx" />
</customHandlers>
</sitecore>
Is what I am trying even possible? Can you get Sitecore to use a custom MediaRequestHandler for a certain folder and then use the regular MediaRequestHandler for everything else?
I am also not really sure I understand how to set up the handlers in Web.Config
. What is the path value? I don't understand what sitecore_media.ashx
is. Can I just make up a different one like I did?
-/media/
ones?sitecore_media.ashx
? Is that a real file or endpoint somewhere? For my custom handler I just made upsitecore_media_secure1.ashx
. Will that work? Second I notice that the prefix used out of the box is-/media/
- is this the same as/media library/
? Is there a difference between /media/ and /media library/?