October 2005 Entries
As I am sure everyone who takes the time to read this article is aware, in November Microsoft releases a huge upgrade to their developments platform, VS2005. (There is also some other releases in this time too, but that is for another article.) Part of that release is a complete reworking of the ASP.Net platform. Not that there is anything disastrously wrong with 1.1, but if you have developed with it for any amount of time, you know where its weak points are. That is, there are not an inordinate number of bugs per-se in ASP.NET, but there are functions that are difficult to implement. I am thinking specifically of Master Pages, Skinning, Dynamic Data Controls, Web Parts, etc. Thus, ASP.NET 2.0 is designed to speed up the development process.

But a better development platform only speeds up development if you know the tools available, and getting learning the tolls in ASP.NET 2.0 is no small task. While much of the framework’s basics haven’t changed, there are a whole slew of new controls to learn about; not to mention how to build portal using web parts, or how web site administration works. While this process is MUCH easier than learning how to build functions by hand (your only option under earlier versions), you still have a learning curve to work through; and fast. We have all seen it before: A year from now when companies finally switch to 2005, they all want developers with 3-5 years experience. So now is the time to learn. (Better still, do a 2.0 web site for a friend or a charity for free. It is great experience, and you can truly say you have been working with 2.0 since it was in beta.)

Always for me the question is: how best to learn all that you need. I am a book reader, but I like books that have examples – complete with source code. I also prefer books that are comprehensive. If I am going to drop the requisite $50 - $60 for one of these tomes, then I prefer the authors to err on the side of too much information. I can always skip the chapter if I feel like I have the topic down. Pro ASP.Net 2.0 in C# 2005 by Matthew MacDonald and Mario Szpuszta is the book for the new version. It is a hefty tome, and it took me a few weeks to get through it. But this is good, ‘cause these guys didn’t skimp or skim. Better still the examples are just as comprehensive, and all the source code is available on line.

The book is directed to a specific audience; that is to say, they wrote this with the expectation that the reader has a base knowledge of web development, and specifically a working knowledge of ASP.NET. (They direct the newbie to other resources.) But they do not assume that since the reader has used this technology before that they know the why’s of a technology, as well as the how’s. This was a pleasant surprise. I find that if I get a glimpse under the covers of a technology, it helps my understanding in the long run. This book has some great examples of this behind the scenes documentation. For example, this book has one of the best explanations of the Kerebos Authentication process that I have seen outside of a Windows Server book. It is worth the price of admission for this alone (I think developers know far too little about this side of development, but that too is another article.)

So I have a new go-to reference that will sit on my shelf next to where I work. You know what I mean. There is always that one book that you reach for when you run across a thorny problem. One that you go for even before the internet, just because you know where to go to find the info you need. It is chapters like the integration of JavaScript and ASP.NET 2.0, that I know I will use again and again. Oh yeah! It’s also available in e-book form. So I don’t have to lug the book to my on-site contracts. Just one last touch from the guys at Apress. I would definitely recommend you pick this one up.

If you are going to be in the Winston-Salem North Carolina area on November 5th, 2005, then come and hear me give a talk on SQL Server 2005 and XML
Web site scraping is a great tool, and it is so easy in .Net. But there are some snags, especially if you are trying to build a robust system that can run unattended. One of these problems are web errors like '999 web site temporarily unavailable.' .Net views these errors as fatal and boom you are out of the program. Now you can catch them then recall the mentod, but this recursive action can eat up memory very quickly. There is however another way:

public static string ScrapeURL (string URL) {
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(URL);
HttpStatusCode code = new HttpStatusCode();
HttpWebResponse resp = null;

try {
resp = (HttpWebResponse)req.GetResponse();
code = resp.StatusCode;
} catch(WebException err) {
return null;
}

string strResult;

using (StreamReader sr =
new StreamReader(resp.GetResponseStream())) {
strResult = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return strResult;
}

Then all you have to do is call this procedure in a do..while (response !=null) loop and away you go. Notice that you avoid stacking up multiple calls because all we are doing here is ignoring the WebErrors.

You can also get more specific and use the code = resp.StatusCode in a case satatement to different things based on the specific HttpWebError. (ie you may want to react to a 404 error differently than you do for a 999 error.
In response to Marcus Eggers' posting, I have added a little info about who I am. Not that I thought he was talking about me specifically, but you never know.....

First off my name is Jeff Tolle. I currently live and work in the Piedmont Triad area of North Carolina. I have many irons in the fire, most of them to do with development using Microsoft Technologies. If you need to get in contact with me, you can use the contact form from this blog. Oh, and Marcus. I am still available to write that article for you. Call me!

Jeff Tolle