<!-- Download Links -->
<!-- Add the rest of your HTML here -->
Some Web Sites do not allow visitors to view the HTML source of their web pages. They can disable our right mouse button to prevent accessing the "view source" menu option and some other web sites open their pages in a special window which has no menu bar to select the "Source" option from "View" menu.
How to get and display the source code
I used the Microsoft
XMLHTTP object in this sample application to get the source code of the web page. It simply makes a synchronous HTTP GET request and displays the response in the browser.
Why this code?
This type of application is already available on the CodeProject website in an article submitted by our friend Dhandapani Ammasai. The extra features in my application are that we can view the source code of any web page as well as saving the source code directly onto our desktop in any supported file format (txt,htm,html,doc etc).
To use the
XMLHTTP object, we need to create an instance of it using
Server.CreateObject("Microsoft.XMLHTTP"). We can then use the
Send methods to get the source code of the web page.
Copy the gethtmlsource.asp and savetodisk.asp files to the root directory (typically Inetpub/wwwroot). You must be running either Personal Web Server on your machine or have access to a web server that runs IIS.
gethtmlsource.asp file in your browser.