Click here to Skip to main content
15,904,877 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
Is there any web-application in dotnet or in html5 which can hidd the source code in our web pages.

thanks
Posted

Short answer: No.

The source has to be there for the browser to read it, and if the browser can read it then anyone can read it. You can use Javascript to make it a bit more tricky, but the user can easily turn Javascript off.
 
Share this answer
 
Comments
Denno.Secqtinstien 21-Nov-11 9:14am    
all right and hand off to all but i have seen on mozilla website that they had redirected the same page on view source which user was trying to open for code ?? how it can be done can any one tell me ?
If im right then u just want to avoid right click on your page..
just paste this script on your page's header tag..

<script LANGUAGE="JavaScript1.1">
<!-- Begin
function right(e) {
if (navigator.appName == 'Netscape' &&
(e.which == 3 || e.which == 2))
return false;
else if (navigator.appName == 'Microsoft Internet Explorer' &&
(event.button == 2 || event.button == 3)) {
alert("Sorry, you are not allowed to right click.");

return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
window.onmousedown=right;
// End -->
</script>

this way, u can prevent user from viewing your code
hope this help u....
 
Share this answer
 
Comments
Denno.Secqtinstien 21-Nov-11 9:14am    
all right and hand off to all but i have seen on mozilla website that they had redirected the same page on view source which user was trying to open for code ?? how it can be done ca nany one tell me ?
Vikas_Shukla_89 22-Nov-11 2:00am    
i hav tried it in my application bt im not facing such prob becoz im using master page.
Thats happens becouse master page might not be there, Use master page for each of ur child one. By doing this, if u press Ctrl+U then it will show only html code for that master page not of child one which contains confidential data..

good luck..
Denno.Secqtinstien 10-Oct-12 6:53am    
thanks dev.vikas.s for your reply. i know the mythology behind master pages but sorry to say i cannot use master page any more due to reason that my application is consist of more then 400 page and each and every page uses a new layout and design.
I have used this code as a solution for my problem

<script type="text/javascript">
document.oncontextmenu=new Function("return false");
</script>

but during googling i saw a portal on mozilla website that they had redirected the same page to view-source:xxxxxxxxxxx and that was showing the design page instid of code. could any one ca ltell me about the same. sorry i forgot to note the url of the page..
 
Share this answer
 
I used the same code for disabling Ctrl + U. but problem persists with the above question.

<Javascript file>

var isnn,isie
if(navigator.appName=='Microsoft Internet Explorer') //check the browser
{ isie=true }

if(navigator.appName=='Netscape')
{ isnn=true }

function key(k)
{
if(isie) {
if(event.keyCode==17 || event.keyCode==18 || event.keyCode==93) {
return false;
}
}

if(isnn){
return false; }
}

if (document.layers) window.captureEvents(Event.KEYPRESS);
if (document.layers) window.captureEvents(Event.MOUSEDOWN);
if (document.layers) window.captureEvents(Event.MOUSEUP);
document.onkeydown=key;
document.onmousedown=right;
document.onmouseup=right;
window.document.layers=right;


<html file>

<html>
<head>
<Script language="JavaScript" src="security.js"></script>
</head>
<html>
 
Share this answer
 
Comments
Denno.Secqtinstien 22-Nov-11 6:46am    
to all


<!DOCTYPE html>
<html>
<head>
<title>MVCHaack Ajax Sample</title>
</head>
<body>

MVCHaack Ajax Demos



<script>
document.location.href = "AjaxDemo/Home/";
</script>
Ajax Demos
</body>
</html>

copy this in a document and save it as .html and then run the code in firefox, a error page will display when i try to get the source code of that page then i found the same page in design instead of codebehind data, any one can suggest me how is it possible ??
Denno.Secqtinstien 29-Nov-11 4:30am    
leaving this discussion till here ... and closing this question.

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