ASP.NET Stop users from Email Webpage

Posted on 2009-05-06
Last Modified: 2012-08-13
Is this possible. I can stop the body of the page from printing when they click the print button.  Is there a way to stop users from email the page from File.Send To?

I know Javascript might be an option.  I just wondered is there is a command from the body tag that I could use.
Question by:aninec
  • 4
  • 3

Expert Comment

ID: 24314791
No way to do this in .net since the command is fired by the browser "client side" and the code you write would be run on the server.

Javascript is likely your only option here, or maybe an active X component (browser plugin).
LVL 39

Expert Comment

ID: 24314907
It is not possible to prevent that. Not by JavaScript and not from the serverside. You may try to create a plugin (XUL for FireFox, ActiveX for Microsoft IE) and ask the users to install it, but you may find some reluctance there.

Btw, you cannot stop the body of the page from printing when they click the print button. You can pull some tricks which may make it slightly harder, but anybody who wants to print your page can and will do that. Internet is a huge open source area and everything that can be viewed can be printed.

Even in the case where you manage to tie the hands of the end user, he or she can still print it by using printscreen, using another browser, disabling javascript, css or plugins, or simply using an older browser.

Same for emailing, which is just equal to save as, which is something you cannot prevent either.

If you want your content protected, you should publish it with PDF, which has protection mechanisms build in (which can, you guessed it, also be bend).

Author Comment

ID: 24319223
This is for an intranet and I am trying to protect content. I think I can use Javascript to control what the users can see.  Most would not have a clue that they could get around the coding...and the rest could careless.

Thanks for the assistance.  Now I need to figure how to code it for No toolbar and menu when the page loads up.
LVL 39

Expert Comment

ID: 24319312
seems to be the day... You're the second that asks that today ;-)

The only way to manipulate the appearance of the browser (whether your users will see it as an annoyance is another subject) is by opening a new window. However, at any time, with all modern browsers, the user can get all buttons etc back. Furthermore, in most browsers it is now a custom that new windows are blocked anyway, and if not, they open in a new tab, which will still show the buttons and menu. And there's no way, no way at all (unless you write a plugin) to remove them. And even if you would manage (let's say by exploing a hole in the security), you will be considered a virus, I'm afraid....
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

LVL 39

Expert Comment

ID: 24319333
But really: protecting content from the ones that do not know how to steal the content anyway, is not really going to bear fruit. And the ones that do want to steal your content, will know there ways around (and in the end it is only one click away to disable javascript).

Your best bet will be to deliver your protected content in any which way but HTML.

Expert Comment

ID: 24372930
what about rendering the content in a new window with no toolbars and preventing right clicks.
that doesn't stop "print screen" of course but it does prevent direct printing to a printer.

Sharepoint has an option to do this with a document, how does sharepoint do it?
LVL 39

Accepted Solution

abel earned 500 total points
ID: 24373011
what about the following (really you can't do much if somebody wants to print your page), which becomes more and more common as default settings... (other browsers have similar ways).

The only serious option is rendering your page as PDF, with the security bits set for printing.

If you want to be particularly annoying to users who want to print your page, add the following in your CSS file, it will have the average user look at a blanco page if (s)he prints it:

@media print 


   * {

       display: none !important;  

      /* the imp. will prevent user-overriding settings in many cases */



Open in new window


Expert Comment

ID: 24373130
oooo good call abel ... i like the css option ... cllean :)

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now