If you embed a WebBrowser control inside of your WinForm you can do this:
webBrowser1.Navigate("http://google.com");
string pageHtml = webBrowser1.Document.GetElementsByTagName("html")[0].InnerHtml;
This will return all of the HTML in the page navigated to.
For Storing Html data in ASP>NET
protected override void Render(HtmlTextWriter writer)
{
using (HtmlTextWriter htmlwriter = new HtmlTextWriter(new System.IO.StringWriter()))
{
base.Render(htmlwriter);
string html = htmlwriter.InnerWriter.ToString();
using (FileStream outputStream = new FileStream(@"C:\\temp.html", FileMode.OpenOrCreate))
{
outputStream.Write(html, 0, html.Length);
outputStream.Close();
}
writer.Write(html);
}
}
No comments:
Post a Comment