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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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.
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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....
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

628 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