简体   繁体   中英

How to open any type (PDF,excel,doc etc.) of file without download option using Asp.net c#

I have tried to achieve by using google docs viewer like below in html template.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>View Document</title>
</head>
<body style="margin: 0px; padding: 0px; overflow: hidden">
   <form id="form1" runat="server">
       <div>
           <iframe runat="server" id="iframe" src="https://docs.google.com/viewer?url=http://infolab.stanford.edu/pub/papers/augmenting.pdf&embedded=true" style="height: 100%; width: 100%; position: absolute;" frameborder="0"></iframe>
       </div>
   </form>
</body>
</html>

It is opening document in new window but download option is exists like below screenshot.

在此处输入图片说明

can any one suggest me to remove pop out button in google docs viewer or please suggest me to any other way to open any type (PDF,excel,doc etc.) of file without download option using Asp.net c# .

Any answer appreciated

Thanks in Advance......!

As far as i know, when you request to open a document on internet they are stored locally on clients machine either in temp file or some browser specific directory in order to display it. Browser can only display local files once they are downloaded. So any user with some technical knowledge have a way to retrieve that file.

1)Few ideas are to open that file in a new page inside a iframe and disable the right click. That might help you user download the file.

2)Also try to set read only permission on the files that way user will not be able to edit/copy the content of the file if that's what you are going to achieve.

3)Also user can print the page which will give them the content of the file, its not like download but i am not sure what restrictions you want to enforce on user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM