UrlRewriter Bug Fix

Date Published: 13 February 2006

UrlRewriter Bug Fix

Some of you may know that I’m pretty interested in caching as a means to improving performance. I also try to tell everybody that will listen that the default method of accessing the ASP.NET cache, as taught in most online tutorials and courses, is wrong. I blogged about the proper caching pattern a while ago, and it’s helped others including my friend Scott Cate for kbAlertz.com. So, given all of that, I thought it was pure irony that the intermittent server error that’s been plaguing ASPAlliance.com for a while now would end up being improper cache access. I’m using the fantastic UrlRewriter from Scott Mitchell, and I located where I thought the bug was and asked Scott if he could get MSDN to update the article download with the fix. He’d long since heard about the error, but as yet the fix is only on his blog, not with the article. Hopefully they’ll update the source article, especially since it is such a great tool for ASP.NET sites so I’m sure many others are experiencing problems as well. In the meantime, I thought I’d blog about it to give it a little bit of a visibility boost and perhaps help a few others correct their implementations (and remember, access the caching using my caching pattern!).

The UrlRewriter cache bug fix:


if (HttpContext.Current.Cache\[“RewriterConfig”] == null)\
return (RewriterConfiguration)\


RewriterConfiguration config =\
if (config == null)\
config = ConfigurationSettings.GetConfig(“RewriterConfig”);\
HttpContext.Current.Cache.Insert(“RewriterConfig”, config);\
return config;
Steve Smith

About Ardalis

Software Architect

Steve is an experienced software architect and trainer, focusing on code quality and Domain-Driven Design with .NET.