I've got authentication set up on certain pages of my website, with anonymous access denied. For regular items/pages, this works like regular forms authentication as you'd expect - click a link or go to the page, you're sent to the login page with a returnUrl query string to send you back where you started after.

This doesn't appear to be the case for media items, though. If I add a link to a similarly-protected media item in a rich text editor, for example, and I click the link, I'm taken to the login page as expected, but no returnUrl property is added on.

Is this normal behavior in Sitecore, or can it be altered to provide the returnUrl for media items? This is Sitecore 8.1 Update 2, if that comes into play as a later fix.

  • I guess this is the default Sitecore behavior. Sitecore media library item requests are handled via media handler - sitecore_media.ashx. Customizing the Sitecore media handler as mentioned above will help you setup the authentication. Commented Jan 5, 2017 at 4:32

1 Answer 1


Looks like this is sitecore's normal behaviour.

Here is the nice article which solves your issue.



  • Setting up <setting name="Authentication.SaveRawUrl" value="true" />
  • creating a new media Request handler that inherits from MediaRequestHandler
  • updating web.config to say sitecore use the new request handler rather than the sitecore's default one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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