Author Options:

view source code of website? Answered

i am developing a browser, i want to show source code(not html code) if user wants and also store it as txt file, help using any language is appreciated, i am using c#, but any language is fine.
thank you


thank you mpilchfamily, for a page the source codes shown by C# program

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

HttpWebResponse res = (HttpWebResponse)req.GetResponse();

StreamReader sr = new StreamReader(res.GetResponseStream());

data = sr.ReadToEnd();


and google chrome are different, both are correct, but c# output is what was written in html (html code), google chrome shows source code of what is being displayed(source code of page), so i want to know how does google chrome do that so that i will use same way in my browser.

Not sure if that is something you have to build into the program. Think that is just a feature of Windows when you right click the window that is using HTML. You get the same options regardless of the browser your using.

Source code of your browser or the web page being viewed?

Source code for your browser: Upload it to a file sharing site for others to download.

Source code for the web page: Web pages are programmed in HTML. So that is the source code.

You do understand that your source code is not viewable once compiled right? When you compile your source code the compile converts it to machine language. So it doesn't matter what language you programmed it in the end result is machine language. Just a bunch of ones and zeros.