The ASPSmith's Blog

Some rants about ASP.NET by Steven Smith

November 2003 - Posts

PDC Sessions
In addition to the powerpoints available at http://www.asp.net/whidbey/ you can also watch the presentations, including demos, in MS Producer format at http://microsoft.sitestream.com/PDC2003/Default.htmOthers have noted this - I mention it here so I can find the link later... :)
Posted: Nov 23 2003, 03:10 AM by ASPSmith | with 6 comment(s)
Filed under:
SYS-CON Radio Interview (PDC 2003)

My SYS-CON Radio Interview from PDC has recently been published on their website (along with a great many other more important people's interviews).  Check them out and download them in MP3 format.

http://www.sys-con.com/dotnet/radio2003/interviews.cfm

Posted: Nov 17 2003, 01:31 AM by ASPSmith | with 2 comment(s)
Filed under:
Speaking At Memphis DNUG
I'll be speaking at the Memphis .NET User Group on Tuesday, 11/18.  I'm going to be giving an overview of ASP.NET Whidbey, which of course has recently been made public at the Microsoft Professional Developers' Conference 2003 in late October.  For more information and directions to the event, see the MNUG website.
Regex To The Rescue For Shorter URLs

I've been redesigning AspAlliance.com off and on for the last several months, and I made a few more changes this morning.  The big one that is noticeable to the general public is the URLs.  Instead of having to link to articles via a viewer ASPX page and a series of querystring values, it is now sufficient to simply append the article ID to the end of the domain name (after a slash), like so:

http://aspalliance.com/1  (article ID 1, which is my Excel Reports in ASP article).

The nice thing about this is that it uses Context.RewritePath, so there is no Response.Redirect and the user never sees the actual URL of the page handling the request.  The regex I'm using is here:

http://regexlib.com/REDetails.aspx?regexp_id=456

The actual code looks like this:

string originalUrl = Request.Url.ToString();
// Check for article shortcuts (e.g. http://aspalliance.com/1 )
string newUrl = AspAlliance.Web.Core.HttpRedirect.GetRedirect(originalUrl);
if(newUrl != originalUrl)
{
System.Uri myUri =
new System.Uri(newUrl);
Context.RewritePath(myUri.PathAndQuery);
}

// GetRedirect:

System.Text.RegularExpressions.Regex regex =
new System.Text.RegularExpressions.Regex(@"\.com/(\d+)$",
(System.Text.RegularExpressions.RegexOptions.Compiled |
System.Text.RegularExpressions.RegexOptions.IgnoreCase));
System.Text.RegularExpressions.MatchCollection matches = regex.Matches(badRequest);
if(matches.Count > 0)
{
  string id = matches[0].Value.Replace(".com/", "");
  int aId;
  try
  {
    aId = Int32.Parse(id);
    return "http://aspalliance.com/articleviewer.aspx?aId=" + id;
  }
  catch
  {}
}
return badRequest;

 

More Posts