Solved

Render HTML from a string

Posted on 2002-07-27
5
598 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
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now