posted on Friday, November 02, 2007 11:11 PM |

enso[1]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.

Tags [ DasBlog ]

Your Comments.

  • # 

    Interesting.

    Glad to see BlogML could help you :-)

    Left by Keyvan Nayyeri at 10/8/2007 6:10 AM
  • # 

    Email me and I'll show you how to redirect ?p=somenumber to permalink.aspx?id=somenumber. You can use the number AS the GUID. So, your dayentry files can use your original wordpress number as the EntryID.

    Left by Scott Hanselman at 10/8/2007 10:10 PM
  • # 

    Ooh, keep usposted on your progress with DasBlog. I faced down the same decision a few months ago but chose Subtext instead as it looked easier to hack into and modify.

    Upside: I'm right.
    Downside: I'm doing a lot of hacking, more than I anticipated. Mostly because I'm a perfectionist, not because of faults in Subtext.
    -Parker

    Left by Citizen Parker at 10/10/2007 12:10 AM
  • # 

    I'm in the middle of re-recompiling Subtext with yet more homebrew hacks, so I'm less concerned about the mysterious partial tags (it used to be a "div>" in the sidebar). Once the re-redesign is up and it doesn't look like dirt that's been screwed by a hobo and then digitized, I'll get the old content back.

    Before Subtext, I used Parker's Awesome Homebrew PHP CMS(TM), a system I built from scratch as an excuse to learn PHP. It was a case study in how to make the wrong, lazy choice at every possible point; I still wake up with night terrors thinking about it sometimes. I was so eager to ditch it and so unimpressed with its content that I didn't bother with a migration.
    -Parker

    Left by Citizen Parker at 10/10/2007 9:10 PM
  • # re: SubText and where I need to modify

    I'm in the middle of re-recompiling Subtext with yet more homebrew hacks, so I'm less concerned about the mysterious partial tags

    Left by anadolu jet at 6/7/2008 5:34 PM
  • # re: SubText and where I need to modify

    trackbacks appear to be foobared on my instance, not sure why they are either. If you want better Live Writer experience, I suggest checking out what Tim Heuer did.

    http://betterthaneveryone.com/archive/2008/04/29/upgrade-time-for-my-subtext-engine.aspx

    Left by Clint Rutkas at 6/7/2008 6:21 PM
Post Comment
Title *
Name *
Email
Url
Comment *  
Please add 5 and 1 and type the answer here: