3

I've noticed that there are URL's that contain dashes, for example:

https://www.bob.com.au/insurance/ski-quote/-/media/carol/Images/Logo/bob-logo-master.svg

Specifically (if it isn't obvious), the dash between the two slashes (.../-/...).

Is this a genuine convention that Sitecore uses for URL's that are supposed to be interpreted by it, or is this an error?

6

Yes, this is a convention that Sitecore uses as triggers for a number of custom handlers:

<customHandlers>    
    <handler trigger="-/media/" handler="sitecore_media.ashx"/>
    <handler trigger="~/media/" handler="sitecore_media.ashx"/>
    <handler trigger="~/api/" handler="sitecore_api.ashx"/>
    <handler trigger="~/xaml/" handler="sitecore_xaml.ashx"/>
    <handler trigger="~/icon/" handler="sitecore_icon.ashx"/>
    <handler trigger="~/temp/" handler="sitecore_temp.ashx"/>
    <handler trigger="~/feed/" handler="sitecore_feed.ashx"/>
    ...    
</customHandlers>

In turn, there are handlers registered in web.config for these triggers:

<system.webServer>
  <handlers>
    <add verb="*" path="sitecore_media.ashx" type="Sitecore.Resources.Media.MediaRequestHandler, Sitecore.Kernel" name="Sitecore.MediaRequestHandler" />
    <add verb="*" path="sitecore_xaml.ashx" type="Sitecore.Web.UI.XamlSharp.Xaml.XamlPageHandlerFactory, Sitecore.Kernel" name="Sitecore.XamlPageRequestHandler" />
    <add verb="*" path="sitecore_icon.ashx" type="Sitecore.Resources.IconRequestHandler, Sitecore.Kernel" name="Sitecore.IconRequestHandler" />
    <add verb="*" path="sitecore_temp.ashx" type="Sitecore.Resources.TempRequestHandler, Sitecore.Kernel" name="Sitecore.TempRequestHandler" />
    <add verb="*" path="sitecore_feed.ashx" type="Sitecore.Shell.Feeds.FeedRequestHandler, Sitecore.Kernel" name="Sitecore.FeedRequestHandler" />
    ..
  </handlers>
  ...
</system.webServer>

In your specific example, the -/media part of the URL causes the MediaRequestHandler handler to serve the request. There are a number of reasons for this, but Sitecore stores the media in the database by default and so needs to process this request (as well as allowing various other functionality such as image resizing).

What I would have expected in this instance though is that the trigger prefix would have been immediately after the domain, i.e.

https://www.bob.com.au/-/media/carol/Images/Logo/bob-logo-master.svg

I would check the value of the Media.MediaLinkPrefix from /sitecore/admin/showconfig.aspx, by default it should be empty in Sitecore 8.1 onwards.

  • Don't you mean /sitecore/admin/showconfig.aspx? – Eric Smith Sep 29 '17 at 2:18
  • Yes, sorry I do, it was a typo. – jammykam Sep 29 '17 at 2:20
  • 1
    Also, check you are viewing the site in Normal mode (use an incognito window if required) and not in Edit or Preview mode, when you are checking the media url that is generated. – jammykam Sep 29 '17 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.