none
How to disable view source of a given web page in asp.net RRS feed

Answers

  • try using following script

    <script type="text/javascript">
    function disableRightClick()
    {
    if (event.button==2)
    {
    alert('For Security Reason Right Click is Disabled')
    }
    }
    document.onmousedown=disableRightClick
    </script> 


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Friday, July 13, 2012 6:42 AM
  • Hi Ashish Tripathi..
    Welcomes you to MSDN forums..

    First,

    This is not rigth forums for ASP.NET realted queries.  Use the following link for post you ASP.Net related queries.

    http://forums.asp.net/

    Second,

    First, you have to know that there is no way you can absolutely protect the source of your page. Any determined hacker will be able to get to it no matter what you do. If the browser can access it to render it, anyone can do it.
     
    To disable the right click button, you just need to handle the onmousedown event:
     

    <body onmousedown="if((event.button|2)!=0){alert('Right button disabled');}">

    You can't, it's impossible. It's nothing to do with ASP.Net.
     
    Your servers send a response back to the client that made the request (e.g. the web browser), it's the job of the browser to interpret and render the HTML.
     
    It's not just a case of 'view source'
     
    Think about all the web developer plugins for Firefox (i.e Firebug) and the built in tools to Chrome + IE that let you view every aspect of the page.
     
    They break your page down into individual components (images, css, scripts, etc) and the end user can see everything about your page! You can't disable these.
     
    So, no is the short answer. Doesn't matter if you have a requirement or not,

    I hope you can clear now


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"


    Thursday, July 12, 2012 1:00 PM

All replies

  • Hi Ashish Tripathi..
    Welcomes you to MSDN forums..

    First,

    This is not rigth forums for ASP.NET realted queries.  Use the following link for post you ASP.Net related queries.

    http://forums.asp.net/

    Second,

    First, you have to know that there is no way you can absolutely protect the source of your page. Any determined hacker will be able to get to it no matter what you do. If the browser can access it to render it, anyone can do it.
     
    To disable the right click button, you just need to handle the onmousedown event:
     

    <body onmousedown="if((event.button|2)!=0){alert('Right button disabled');}">

    You can't, it's impossible. It's nothing to do with ASP.Net.
     
    Your servers send a response back to the client that made the request (e.g. the web browser), it's the job of the browser to interpret and render the HTML.
     
    It's not just a case of 'view source'
     
    Think about all the web developer plugins for Firefox (i.e Firebug) and the built in tools to Chrome + IE that let you view every aspect of the page.
     
    They break your page down into individual components (images, css, scripts, etc) and the end user can see everything about your page! You can't disable these.
     
    So, no is the short answer. Doesn't matter if you have a requirement or not,

    I hope you can clear now


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful"


    Thursday, July 12, 2012 1:00 PM
  • try using following script

    <script type="text/javascript">
    function disableRightClick()
    {
    if (event.button==2)
    {
    alert('For Security Reason Right Click is Disabled')
    }
    }
    document.onmousedown=disableRightClick
    </script> 


    Mark Answered, if it solves your question and Vote if you found it helpful.
    Rohit Arora

    Friday, July 13, 2012 6:42 AM
  • Thanks Rohit ,

    this is working for mouse right click , how to disable for key board right click button?


    Ashish Tripathi [SSE]

    Monday, October 1, 2012 7:29 AM