Added some database stuff…

What’s up?

Well, I’ve been working hard on some technical stuff. Tonight I took some
time to get a handle on a nagging database problem that has been causing me
fits, the result is the cool and happening stuff on the side of the
weblog.soulhuntre.com page that tells
you what I am reading and so on. This turned out to be not only a database
issue, but a good excursion into
ASP.NET remote HTML
inclusion. I wound up making a user control that does it, and I’m sticking the
code at the bottom of this entry, if you don’t see it try the [more] link.

Lots of other stuff happening, but I am going to sleep.

This is "scrape.ascx" – the custom control that will grab a web page and
output it

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>

<script language="C#" runat="server">

	public String url = "";


	void Page_Load(Object Src, EventArgs E) {
      scrape_internal.Text = readHtmlPage(url);
   	}

   	private String readHtmlPage(string url)
   	{
      String result;
      WebResponse objResponse;
      WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
      objResponse = objRequest.GetResponse();
      using (StreamReader sr =
         new StreamReader(objResponse.GetResponseStream()) )
      {
         result = sr.ReadToEnd();
         // Close and clean up the StreamReader
         sr.Close();
      }
      return result;
   	}

</script>

<asp:literal id="scrape_internal" runat="server"  />

Here are some snippets of code to show you how to use it in a page

( before the <html> tag)

<%@ Register TagPrefix="wsc" TagName="indications" SRC="/_someplace_/modules/scrape.ascx" %>

( somewhere in the body of the page )

<wsc:indications id="wsc_indications" runat="server"
	url="/network/export/indications.aspx" />

Anyway, enjoy!