How to hide view source - c#

Could some one please help me out to hide a view source option of a web page in dot net ?

You can't, it is an option of the browser. The best you can do is obfuscate it.

Back in the Geocities era of the internet it wasn't uncommon for sites to use javascript to capture right clicks and popup a message box saying that you weren't allowed to view the source (or save an image or something).
This isn't quite so common nowadays for three main reasons:
It was futile. Preventing someone from using right click to view the source did nothing, as there are plenty of other ways to get at it. It was a minor inconvenience at best. If the browser can render the HTML, the user can get at it too.
It was annoying. Not just the modal message box whenever you accidentally right clicked. Arbitrarily removing functionality from the user's browser is a no-no.
It serves no purpose. If there is some reason that you really don't want the user to see the source of the website then there is something really wrong. If you are doing it to hide how bad the code is, fear not, terribly awful code makes it to production all the time. If you're doing it out of security then this is a majorly bad decision. Security through obscurity (on its own) is never the right choce.
That said, there are ways of obfuscating the code such that the browser can still parse it, but that it is at least annoying for a human to do so. You can use javascript to write certain parts of the page (a la AJAX) such that viewing the vanilla source code doesn't show what it actually rendered. Or you can compress it removing all formatting and naming elements (once it goes to production) such that it is at the very least annoying to follow.

If you're dealing with Internet Explorer only, you can use Group Policy to disable the Internet Explorer View Source menu item.
See Group Policy entry: View menu: Disable Source menu option.
Group Policy modifications are usually made through gpedit.msc or Active Directory. However, in the most basic scenarios changes to Group Policy can be made via direct edits to the registry.

Related

When developing a web app, when does the changes takes effect and when do the browser uses its cache?

Its a general question, please tell me if it is not approved to be on this site and I will close it if needed.
The questions is, When I am developing a web application, Some times I only need to save the file I am working on(not even build the project) and the changes appear when i load the site. sometimes they appear only when I build the project. and sometimes they appear only when I build the project and clean the cache.
I am trying to understand the logic behind how it works.
TY.
Your question is very vague hence difficult to answer appropriately but in any case, I believe what you are referring to is the difference between static and compiled portions of your web application.
The best answer I can give you is that if the changes you make are in code that will have to be compiled, those changes will not show in the browser until the binaries are created (which will probably only happen if you "build" your project), if the changes are in code that is interpreted (HTML, CSS, JavaScript, etc) those changes will not require compilation as the browser will be able to interpret them as long as the file has been saved.
I hope that answers your question.
It depends on browser settings.
I strongly recommend set the browser not use cache.
The setting below is effect on IE and Chrome.
I hope this helps.
Preventing future caching issues
To reduce some potential caching issues, it's best to have Internet
Explorer set to request the latest version of the page rather than
relying on a cached copy. To do this:
From the Tools menu choose Internet Options.
On the General tab, under Browsing history, click Settings.
Under "Check for newer versions of stored pages" make sure "Every
time I visit the webpage" is selected.
Click the OK button.
http://agsci.psu.edu/it/how-to/clear-internet-explorer-8-ie8-browsing-history-cache

Custom editing functionality for SharePoint web parts

I am trying to develop web parts with custom functionality for editing for normal users. In the chrome bar there would be the same sort of controls as you see in the top right of your browser (except with a triangle instead of a line).
Triangle is to minimise/restore (as in OOB, but with different display)
Square is to maximize a new module type window, probably with an iFrame displayed in a module type view window with jQuery with an additional field to add the url to where it should go
Cross is to delete web part
The functionality is required across a few different types of web parts including calendar, CBQ, Data View, CBQWP, and would ideally be a part of a custom chrome that would be added to them. I don't do back end code so I'm finding it hard to get my head around how someone would put together the functionality. Unless it's simple it won't be me writing this functionality. I have Enterprise 2010 for development, but the people using the control would only have foundation.
I'm basically after opinions about how this would be done. I think it should be a custom control written into the chrome, if that's possible. Does that seem feasible or is there a better way of doing it?
I would really appreciate any advise, even if it's just that it would be better to skin the existing chrome and leave the functionality as is. There's leeway with the functionality so at this stage it's deciding on how best to do it if it's possible or not too bother going down that route.
Thanks very much in advance!!

Programatically deactivating a feature in Internet Explorer

I'm currently developing a plug in for Internet Explorer, and there's a certain feature in Internet Explorer that's bothering me.
There's this feature in IE that's been appearing at least since IE7 (I couldn't check earlier versions), that lets the user modify the sizing of HTML elements in editable windows (such as a rich text mail in GMail), just by clicking on the element and dragging the sizing box. This modifies the style of the HTML element (such as a <img> or a <div>).
My first problem is that I don't know the name of that feature. I've searched and searched, but I haven't been able to find a thing.
My second problem is that I need a way to either turn it off, or at least to work with it, programatically. In my plug in, I need to modify the DOM in webmail clients to modify certain things that the user types. The problem is that for some reason, the behaviour of my plugin varies if an HTML element is selected using this feature in the edit window of the webmail. I need to, at the very least, be able to detect if anything is selected this way.
Any help will be appreciated. Thanks a lot!
You're probably talking about Internet Explorer's Accessibility Features, which are designed to assist the visually impaired to use websites. Visual impairement can take many forms, and it's generally considered very bad form to take away any tools designed to assist users in their efforts to effectively use the Internet.
Don't make your users work harder to use your site. You get paid to write software that's easy to use and makes life simpler. If your site doesn't do that, your users will find one that does.

How to alter browser's back button functionality similar to eCommerce sites in asp.net

I have a web application, in which browser's back button functionality should be customized. It's like, whenever we click on browser's back button, it should take us to landing page(Login page), It should display error message saying that 'session expired. Please login again'.
I have gone through so many posts and even in stack overflow also, i saw few posts. But nothing worked for me. The java script approach i am using as a temporary workaround.Basically this JavaScript never allow us to go back. instead it will keep us in same page.
JavaScript i have used <script>history.go(1)</script>
Please help me to customize the functionality of Browser's back button.
Any suggestions will be really helpful to me.
Short answer: You cannot
A little longer: You shouldn't even try.
But if you insist: A Thorough Examination of "Disabling the Back Button." (from 2000, but since it is ASP I guess still valid for you :)
Newer dot net: Restrict user go back to previous page after signout
Ignore the older browsers do not support location.replace - IE3.2 is not considered older any more but ancient.
For this - you would need a custom solution and disabling back button will not help...
Usually you should not try to change the behavior of back button. But since this is the requirement, I would suggest the following:
Approach 1:
This calls for creating a navigation framework where you know which is the current page in the flow... This is only possible if you a sequence in which the pages will be called (like a wizard)
Approach 2:
Specific to your case : You can use jquery/javascript to identify if the back button is clicked.. If it is then you can do an ajax call to server to kill the session and then redirect the user to login page.
You can programmatically manipulate browser history using something like this:
window.history.back();
window.history.forward();
window.history.go(2); etc.
In HTML5 ready modern browsers like Chrome you can also do more advanced things including completely overwriting back button functionality using history.pushState() and history.replaceState() methods.
(https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history)
You can also go dirty and use javascript + ajax calls to react specifically to back button events, but this will also not work on some browsers. What you ask is not a native part of a web, so no matter what you will decide to use in the end, it wont be very easy or widely supported.

A browser inside a browser

I want to create with Asp.net a browser inside a web page, so that I can process the click events of the user (for statistics analysis).
I kwnow how to do it with Winforms but I need a full online solution, so that:
The user open an standard browser and types in a start url.
In this url the menus and bars of the standard browser are hidden and
the user can see a "simulated browser", with standard buttons
(back, reload, ...).
From the Asp (c#) code behind this page I can start collecting click
data.
Thanks in advance, and keep the good work.
What you want to collect (a heat map of clicks essentially) is doable, but I don't think the way you want to go about it is very feasible.
Try this out.
I think that using this kind of solution with frames, etc. is much more feasible than embedding a browser (this amounts to writing a browser that can be served up by some kind of java/silverlight technology, not trivial).
Another idea would be that since, I assume, you have the permission of your users to track their clicks, write a greasemonkey (firefox plugin) based on the javascript in the link I provided above. You could then have all users use this plugin script combination to give you their clicks.
Web browsers are normally designed to prevent this kind of cross-site scripting vulnerability. This would only be feasible if you had the complete cooperation of all sites involved.
I don't think browsers will allow you to do this, for the simple reason that it opens up a whole bunch of security holes. If you think about it, an attack site designed like this would be able to follow people around the net tracking their actions, stealing passwords, etc. without them even knowing it was there.
This is not so simple for a web app.
Your options are:
Create a plugin (or Greasemonkey script) for your favorite browser to collect click data.
JavaScript that tracks the user's cursor position. Keep in mind that this won't be reliable if your users go to other sites from within your site thanks to the fact that JavaScript doesn't work well if scripts come from different origins.
You won't be able to make a "browser" control like you can on a desktop app because browsers intentionally don't allow web sites to be that powerful.
For the "browser in a browser" effect, you can use the tag. Remember, you'll only be able to track user actions in this iframe if the source is from the the same domain as the page it's included on.
Cross domain scripting is impossible by client-side. For obvios security reasons, you can't even read from a frame or iframe pointing to somewhere not from your own site.
Maybe the solution here is to to build something similar to the famous PHPProxy, or PHPBrowser, in this case a "ASP.NET Proxy". Its not that hard to build, you can Google for many exemples of those little codes.
While I doubt you can hide the original browsers toolbars etc, you could set up a single page that does this (it certainly wouldn't handle everything though).
This page would contain a the buttons and textbox required (to make up the inner browser UI) and a placeholder that would contain the page that the user requested. Of course the page contained in the placeholder will need to have all the links replaced so that they can be tracked (I would use linkbuttons). I'm not sure how well form submits would work.
Personally I'd use a proxy if I had control of the computer.

Categories

Resources