Last night, I was at the Bennett Adelson .NET SIG meeting. Miguel Castro came out and talked to us about URL Rewriting, HTTP Modules, and HTTP Handlers.
Where was this guy a few months ago when I had to figure this out on my own for a project at work?!? All the points he had hit on in his presentation are things I ran into a few months back while implementing rewriting on our main site at work.
First off, a little on Miguel… contrary to what some of the guys had teased me about, he’s not Fidel’s long lost brother from Cuba (or at least not that he admitted to). Miguel is an INETA speaker from New Jersey, and he is SteelBlue Solutions. He kept plugging his program CodeBreeze throughout the presentation, and the poor guy in front of me became his target. He had to remember Episode 77 on dnrTV was the show where Miguel mentioned CodeBreeze. But for all that Miguel talked about URL Rewriting, he still hasn’t set up http://www.steelbluesolutions.com/CodeBreeze to forward to CodeBreeze. (So if he actually sees this, the URL expectation has not been met.)
If you ever get a chance to see Miguel talk, go for it. This guy is quite animated when he talks, and he seems to thrive on audience interaction. Unfortunately, his audience last night was mostly dead.
Miguel covered various ways of rewriting URLs, including:
- <urlMappings> section in web.config
- Good for 1-to-1 hard-coded relationships
- Syntax for adding a mapping to this section:
<add url=”friendly_looking_URL_that_doesnt_necessarily_exist” mappedURL=”intimidating_URL_that_better_exist” />
- Application_BeginRequest in Global.asax
- Good for application-specific logically-determined mappings
- Not good from a reusability standpoint
- Reusable HTTP Module
- Can tap into the same events as Global.asax
- Compiles into a DLL, which is great from a resuability standpoint
- Easily setup in the <httpModules> section of web.config
- Re-write Plug-Ins
- Uses OnBeginRequest
- Is a strategy pattern, for those who follow design patterns
- Regular-Expression Engine
- Uses regular expressions that are setup in web.config
- Built as a plug-in
- Custom HTTP Handler
- Also compiled into a DLL, similar to a HTTP Module
- Difference between Handler and Module is that Handlers are associated with specific extensions and wild cards
- Setup in the web.config <httpHandlers> section
- Handlers are assigned AFTER the OnBeginRequest
He went on to talk about Search Engine Optimization, in relationship to URL Rewriting. The bots index a “rendered” page and then crawl the site through other links on the pages. If you have your friendly links on your page, there’s a good chance that it’ll get ranked higher. (Argh… and I apparently slacked off in my notes, as there was a part where he mentioned one of his products and we laughed at its name and led Miguel to a realization about that name.) Though having “sex” in the name probably helps with SEO 😉
After the meeting, a group of us ended up at The Winking Lizard. Just like last month, it was a lot of storytelling, laughing, and hanging out with people we knew and new people… always a lot of fun!
Next month, Richard Broida is giving his talk “The Intelligent Programmer’s Guide to BizTalk”. I’ll admit now that I have no idea what that’s about, but I’ll at least go to see what it’s about and to hang out with them afterwards.