The other day I blogged about potentially switching to blogengine.net but one of the major issues is ensuring the URL’s I have in dasBlog either continue to work or redirect accordingly. To that end, I started investigating URL rewriters for ASP.NET and found this post of ScottGu’s very helpful. He mentioned two different Open Source rewriters and I opted for UrlRewriter.net which describes itself as:
UrlRewriter.NET is an open-source, light-weight, highly configurable URL rewriting component for ASP.NET 1.1 and 2.0. UrlRewriter.NET provides similar IIS Rewrite capabilities that the Apache web server provides with mod_rewrite and .htaccess. You don’t need to install an ISAPI Rewrite filter to use the component. Best of all, UrlRewriter.NET is free and licensed with a very permissive MIT-style licence.
I found it to be all of the above and the install/configuration to be very straightforward not to mention it has good online help and a support forum.
One caveat that I ran into though was that once installed at the root I started seeing this error in my other ASP.NET applications:
Server Error in '/blog' Application.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'Intelligencia.UrlRewriter' or one of its dependencies. The system cannot find the file specified. (E:\web\xxxxxxx\htdocs\web.config line 11)
Source Error:
Line 9: <system.web>
Line 10: <httpModules>
Line 11: <add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter" />
Line 12: </httpModules>
Line 13: </system.web> |
Source File: E:\web\xxxxxxxx\htdocs\web.config Line: 11
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433
The Fix
To fix this I added the following to the web.config files of my other ASP.NET applications removing the new assembly dependency:
1 <system.web>
2 <httpModules>
3 <remove name="UrlRewriter" />
4 </httpModules>
5 </system.web>
If you’re aware of other options that don’t require changes to every web.config I’d love to hear about them. At any rate, while I haven’t decided to switch blog engines yet I now have the pieces in place to do just that.
What do you use for URL rewriting particularly in a hosted environment?