posted on
Friday, November 02, 2007 11:11 PM |
Well, I got hacked in support in the Cacher.cs, UrlReWriteHandlerFactory, and adding in a httphandler.
It took a bit of tracking down but due to you mentioning the UrlRewrite Engine, I figured out it only matches the path, not the RawUrl. Added in || handler.IsMatch(context.Request.RawUrl to the if statement. Line 77 in the UrlReWriteHandlerFactory.cs in the GetHandler method
The Cacher was GetEntryFromRequest(CacheDuration cacheDuration, bool allowRedirectToEntryName) method and checking if there was a query string and if it was p or page_id then check if it was numeric. If so then move on with how the function worked.
The regex for the httphandler in the webconfig was (?:default\.aspx\?(p|page_id)=\d+)$
...
SO how did I actually figure out how to do this? Besides being awesome and semi-bored on a Friday night after work, I did what every good developer does, debug. Yes, this isn't the first web project I've worked on. Yes, I did this professionally for a bit. Yes, I work for Microsoft. And yes, you too can do what I just did. It really isn't that hard if you read and have a little help.
The SubText project is a decently sized and coming in fresh is like putting a teenager in the playboy mansion and telling him to make his move and expect him to actually be successful at the end of the night.
I posted a question on the Subtext forum and got a bit of guidance on my question. Steve Harman gave me a rough idea on where to look and I had figured out one area to look too. From there I started to debug.
I actually never used a HttpHandler before but looking at the webconfig, I knew that was an area I had to start poking around in. I found in the UrlReWriteHandlerFactory that it had all the handlers with the nice Regex pattern I knew I needed to match. Since I had the code working in the Cacher but couldn't get it to work with http://test/?p=40 but it worked with something like http://test/page/40/40/03?p=40. SO this told me a few things.
SubText wasn't respecting a full URL, just the Path. So I started to add break points where I thought code may start firing off. I knew I had to start looking at HttpHandlers so that is where I started looking. In the UrlWriteHandlerFactory I found what I was looking for. I added in the extra check for the RawUrl on top of the Path.
Simple as pie, right? Next time I'll record me debugging and doing a diagnostic diagnosis to figure out what is wrong. It will be like an episode of House just with more swearing and showing off exactly how wrong I normally am and how blogging my success magically erases all my mistakes.