URL rewriting in ASP.NET and web.config settings


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?

4 thoughts on “URL rewriting in ASP.NET and web.config settings

  1. I’ve been experimenting with the url routing inside asp.net mvc. I’m trying to move from community server to blogengine.net and use redirection from the old blog posts to the new ones.

  2. Hey John,
    Good to hear from you! I don’t think you’d be disappointed in UrlRewriter.net if you decided to go that route. If not, I’d be really interested in your findings regarding the MVC framework URL routing.
    Good luck!

  3. hi steve,
    In my project url rewriting is not working propoerly. I send id value in query string and in url rewriting i use id value as url name.Its working but there is problem in designing if i use url rewriting. I made designing with the use of url. Please give me suggestion. THANKS in advance.

  4. hi there.
    i have some proublem in a query of group by in sql server 2005
    can u help me out

Comments are closed.