Frage

I could see blog post from 2011 recommending using "-" instead of "~".

What is the best practice to write media URL in Sitecore 6.5 on .NET 4.0/IIS7.5? Should I keep default /~/media/ or follow blog post advice using /-/media/ or while I am there, why not just use /media/?

War es hilfreich?

Lösung

I suspect the use of ~ is for legacy reasons. The current recommendation is to use -/media as you point out, but you could use whatever you wanted and it would work. The issue you have just using /media/ is if there is any other item with that as part of the name then it will trigger the media handler, rather than serving up your content for example.

For example, as request for /blah/blah/blah/-/media/images/logo.png will serve up the image correctly, /about/media/news/2013/12/20/sitecore.aspx should in fact serve up a page but will trigger the media handler and return a 404 just using /media/. So if you are going to use something else then make sure it is unique, you may need to enforce it since content editors can be a bit funny about remembering things like this.

Since you are currently using Sitecore 6.5 then I can assume you have existing content. Make sure you leave the existing ~/media trigger to allow your Rich Text fields to continue to work

If you update the Media.MediaLinkPrefix setting on a system that already has some content in a database, Sitecore may not update the values in all Rich Text Editor fields that contain values in the old formats, including inline images and links to media items.

Sitecore Idiosyncrasies: Media URLs

I would probably go ahead and set Media.RequestExtension to an empty string so that image urls are served up with the correct media extension too.

Andere Tipps

I know this problem appear just when are you using .Net Framework 2.0

Please see next link . If you run your website under .Net Framework 4.0 and IIS 7.5 you don't have this vulnerability.

Also this document explain a little bit about using of tilde.

Also you can check John West blog about /~/media

So the conclusion is use -/media for media files.

For projects using Sitecore 7.2, you may want to stick to using a tilde or apply the hot-fix mentioned in the following KB article.

https://kb.sitecore.net/articles/998758

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top