SaaS CMS has officially launched! Learn more now.

Get full URL to media file...


Hi guys, 

In the Episerver back office I have a content refrence that has a PDF file as its data.

On the front end (Razor view) I am using this code to output the PDF


When a user clicks this link, the PDF is opened in the browser, I want the browser to download the PDF and NOT open it in the browser.
One thing I noticed is that the URL genrated is /globalassets/PDF-File-Name........ but this URL is not the URL to the actual location of the PDF file, how can I get this URL? and how can I force the browser to download the PDF rather than open it?

Apr 24, 2018 11:12

What do you mean that the /globalassets/PDf-- etc is not the url to the actual location? My guess is that it IS the url to the file in the Episerver media archive. What do you expect it to be?

Apr 24, 2018 16:00

Same as my answer on StackOverflow... just append /download to the URL and a download will be foreced (for browsers who honor this).

Apr 24, 2018 16:48

You can't link the file like that. You would need to have a controller or something which returns headers so browser know it should download the file. One option is to make the link to an action which returns FileResult, passing the content guid. 

Edited, Apr 24, 2018 16:50

/download will set those headers that will trigger a download.

Apr 24, 2018 16:52

Sidenote; if you append /thumbnail (or the name of another thumbnail property in your content/media type) to an image URL you will get the thumbnail.

Apr 24, 2018 16:54

Johan Petersson - Your answer was what I was actually after, I only wanted the "REAL" url thinking that would change the way the browser deals with it....

so adding /download worked but what I want to know is why... is that an episerver thing or just a genric thing you can do with PDFs?

Apr 24, 2018 17:49

Why is because Episerver sets the correct http response headers when you append /download. E.g.:

Content-Disposition: attachment; filename="filename.pdf"
Apr 24, 2018 19:16

You also might want to set the download attribute on the anchor, please see

Apr 24, 2018 19:18
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.