Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more: , +
Dear,

I have a request from my Business owner to prevent user from downloading report.
Now i am displaying my report in browser using the following code:
C#
private void DisplayReportInBrowser()
        {
            // Variables
            Warning[] warnings;
            string[] streamIds;
            string mimeType = string.Empty;
            string encoding = string.Empty;
            string extension1 = string.Empty;

            // Setup the report viewer object and get the array of bytes
            byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension1, out streamIds, out warnings);
            Response.Clear();
            Response.ContentType = mimeType;
            Response.Cache.SetCacheability(HttpCacheability.Private);
            Response.Expires = -1;
            Response.Buffer = true;
            Response.AppendHeader("Content-Disposition", "inline; filename=Testing");
            Response.BinaryWrite(bytes);
            Response.End();
        }


but i can't disable the download button which is rendered in browser.
Is there is any way to achieve that?

What I have tried:

i tried disabling the download button but it didn't work.
Posted
Updated 8-May-16 0:32am
Comments
Mehdi Gholam 8-May-16 6:08am    
If you can read something then you can download and save it.
_ProgProg_ 8-May-16 6:10am    
Couldn't i disable the download button?

1 solution

You have to understand, that the very moment you display something on a web page that content is on the end user's machine...
So even you prevent from downloading the pdf file behind the report, the end user can save it page-by-page (like paging and hitting 'Print Screen'), so the report is there...
If you want to prevent such situation, than use an authenticated site or send out the report only the people can have it using email...
As SA suggested: As you cannot prevent the end user from keeping the information in the report at the moment it was displayed by the browser, you may consider narrowing down the number of persons who can do so by using some authentication method or by sending out the report only to people with proper rights, using e-mail…
 
Share this answer
 
v4
Comments
Sergey Alexandrovich Kryukov 8-May-16 9:08am    
5ed, but "if you want to prevent" part won't work either. :-)
A number of inquirers here really play with the idea that something can only be viewed on screen online, and never again. This is not just the failure to understand technical aspects; it's much worse...
—SA
Kornfeld Eliyahu Peter 8-May-16 9:10am    
Thank you!
"If you want to prevent" part was aimed to the idea not let unauthenticated people to see/download the content, and not toward meant to prevent the download at all...
Sergey Alexandrovich Kryukov 8-May-16 9:23am    
Yes, I understand. I would just suggest you remove "to prevent such situation" or re-phrase it, to indicate that the goal itself should be changed.
—SA
Kornfeld Eliyahu Peter 8-May-16 9:28am    
English is not my best part...See the update...
Sergey Alexandrovich Kryukov 8-May-16 9:35am    
I hope you won't mind my editing. I feel the major problem is that you did it too fast. There were many usage and similar minor errors; my fix was also very quick, so I cannot guarantee that I fixed it all correctly, please review.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900