Why my app shows only a few lines of HTML-code of a webpage, and IE shows it all.

Peter Kiers
Peter Kiers used Ask the Experts™
on
Hi there,

I have searched on the internet for examples to get the whole HTML-code of a certain webpage. Alle these examples just get me a few lines. The strangest thing is when I take f.e: Internet Explorer, right-click on it and choose Display Source in the context-menu I get a new windows with all the HTML-code of that page. When i do the same with Mozilla Firefox I get also a few lines. Does someone know why my application and Firefox shows only a few lines of code and IE shows it all. Who knows why, and how to solve this problem in my application.

Greetings, Peter Kiers
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
can you provide the webpage url?
Peter KiersOperator

Author

Commented:
Unfortunally not. The url is an url i have logged into. Peter
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
It is difficult to help you when you can't give the info to check the problem.  However... it sounds like there may be an error on that page.
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Peter KiersOperator

Author

Commented:
I have a webbrowser on my form that displays a page. When I right-click on the webbrowser and select display source in the context-menu i get the full html of that page. I have also create a button with the following code:

        private void bbGetHtml_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            String source = ("source.txt");
            StreamWriter writer = File.CreateText(source);
            writer.Write(webBrowser1.DocumentText);
            writer.Close();
            Process.Start("notepad.exe", source);
        }

Open in new window


I get only a few lines.

How can I sove this?

Greetings, Peter Kiers
Peter KiersOperator

Author

Commented:
And I like to mention that the website uses a frameset!

Maybe that is the problem. But how to solve this?



Peter
Operator
Commented:
AAAAAAAAAAAAAAAAHHH GOT IT:

The reason why I only get a few lines of a site. Is because the site uses a frameset:

And this does the trick:

string html = string.Empty;

// webBrowser1.Document.Window.Frames gets a collection of iframes contained in the current document...
// HTMLWindow is the iterator for the Collection...
foreach (HtmlWindow frame in webBrowser1.Document.Window.Frames)
{
html += frame.Document.Body.OuterHtml;
}

Open in new window


Greetings, Peter Kiers
Peter KiersOperator

Author

Commented:
Found my own solution

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial