Solved

Render HTML from a string

Posted on 2002-07-27
5
608 Views
Last Modified: 2010-04-15
I have a windows app that checks URL response time of our various web sites.  Right now it just checks the URL response time by using the HttpWebRequest class and downloading the sites html.  

I want to add an option to render the html that was downloaded.  When the page is rendered it would obviously download all the images of the site and timing that would also be useful.

When I am finished downloading all the html it is stored into a string.  How can I render the html in this string.  At this time I do not intend on giving the user the option of viewing the rendered page so if it doesnt render 100% correct like it would in Internet Explorer its not a show stopper.  I am mainly concerned about the amount of time to download all the content from the html (images, etc).

Thanks
Darrell
0
Comment
Question by:larockd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Accepted Solution

by:
sdn421 earned 100 total points
ID: 7185702
You could write the string to a file and then open the file.

using System;
using System.IO;

string fileName = "myFile.htm";          
FileInfo file = new FileInfo(@"C:\acc" + fileName);

StreamWriter sw = file.CreateText();    
sw.WriteLine(htmlString);              
sw.Close();

You could also use an IE control as an ActiveX component.
Add a reference to "Microsoft Web Browser" in your project. You can then use this object to navigate and display the web page.

I am not sure if this is what you are looking for.  Let me know if you need something else.

Good Luck.

0
 

Author Comment

by:larockd
ID: 7186821
Basically what I am looking for is a way to render the page in the background.  It does not matter if the user sees the rendered page.  The whole purpose for the rendered page is to time how long it takes to download the whole page.

For example if you have two pages and they each display one image and the one page's image is 5K and the other pages image is 5 megs then the time it takes to download each page's html will be close, but the amount of time to download the pages associated parts (images) will dramitically differ for both those pages.

I am interested in using the activeX web browser control how would you do that?

dl
0
 
LVL 14

Expert Comment

by:AvonWyss
ID: 7241536
With your approach, you will always have to wait until the page has finished loading until you know how long it takes. And the time you measure may be completely wrong in several situations: if the user is downloading something else from the net, or if the server or connection to it is unusually slow.

Therefore, what I would do to solve your task, is to parse that HTML file yourself, finding any IMG, LINK REL, EMBED, OBJECT etc. tags, then request these with a HEAD request (which will return the content size without actually downloading it). Add all the sizes together (plus some bytes for protocol overhead if you want accurate numbers) and divide it by the speed of the targeted connection (e.g. how fast would it be on a cable connection, or on a crappy old 28'800 modem?).
0
 

Author Comment

by:larockd
ID: 7243272
AvonWyss,

The reasons you site for the time being skewed is exactly what my program is attempting to monitor.  My program is not intended to give you an ideal response of a webpage load, but it is intended to alert you to problems such as poor connections, saturated paths, etc.  

Darrell
0
 
LVL 20

Expert Comment

by:TheAvenger
ID: 9506469
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
Accept a comment by sdn421
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

TheAvenger
EE Cleanup Volunteer
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question