1

I have a pdf saved to Azures Blob Storage, so I have a url of where the file is stored :

https://appname.blob.core.windows.net/...filename.pdf

When trying to get this to open in a new tab, it downloads it instead, however it works when the file is stored within my MVC app's local storage. I am using the following code:

<p>Click here to view file: <a href="@Model.FilePath" target="_blank">Click here</a></p>

I have read that its browser settings that need to be changed - I have checked in chrome and made sure that "download pdf" is set to no, but its still doing it.

Is there any way I can get this pdf to still open in a new tab instead of downloading ?

Thanks for any help in advance.

AxleWack
  • 1,679
  • 16
  • 32
  • As far as I know, PDF will only open in browser, if it stored physically in some folder structure. You have saved it as BLOB in db. so, when you try to open it, it is downloading instead of opening as file is not available as readable format – Ubiquitous Developers Nov 12 '18 at 06:13
  • Can you provide controller code which returns the file? Try setting `Content-Disposition` header with `inline` and use stream instead. – Tetsuya Yamamoto Nov 12 '18 at 06:14
  • you should check this first : https://stackoverflow.com/questions/11805944/azure-blob-always-downloads-when-navigating-to-url – Ubiquitous Developers Nov 12 '18 at 06:16
  • Thanks @UbiquitousDevelopers I will check it out quick – AxleWack Nov 12 '18 at 06:17
  • @UbiquitousDevelopers Thank you for this! It did exactly what I wanted. How do you want to handle this ? As this now feels like a duplicate to the link you provided.... Do you want to post it as an answer, or want me to delete the question rather ? – AxleWack Nov 12 '18 at 06:27
  • 1
    @AxleWack - No that's fine, I am here to help not for points. you can keep question – Ubiquitous Developers Nov 12 '18 at 06:31

1 Answers1

-3

You can add Docs PDF/PowerPoint Viewer in to chrome to view PDF instead of downloading it.

saddeepM
  • 11
  • 3
  • 1
    It is web application, so not every user will add this plugin to their browser. AxelWack needs general solution that works on every browser for all users – Ubiquitous Developers Nov 12 '18 at 06:25