R – URL rewriting problems with ASP .NET 2 on IIS7 and Vista

asp.netiis-7url-rewritingwindows-vista

I've got a website running under ASP .NET 2/IIS7/Vista. I have a URL rewriting module which allows me to have extensionless URLs. To get this to work I have configured the system.webServer section of the config file such that all requests are forwarded to the aspnet_isapi.dll. I have also added the URL rewrite module to the modules section and set runAllManagedModulesForAllRequests to true.

When I start up the website and visit one of the pages that uses the URL rewriting, the page is rendered correctly. However if I then visit another page the site stops working and I get a 404 not found. I also find that my breakpoint in the URL rewriting module is not getting hit. It's almost as if IIS forwards the first request to the rewriter, but subsequent ones go somewhere else – the error page mentions Notification as being MapRequestHandler and Handler as being StaticFile.

If I then make a small change to the web.config file and save it, triggering the website to restart, I can then reload the page in the browser and it all works. Then I click another link and it's broken again.

For the record, here's a couple of snippets from the config file. First, under system.web:

<httpModules>
  <add name="UrlRewriteModule" type="Arcs.CoopFurniture.TelesalesWeb.UrlRewriteModule, Arcs.CoopFurniture.TelesalesWeb" />
</httpModules>

and then, under system.webServer:

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <add name="UrlRewriteModule" type="Arcs.CoopFurniture.TelesalesWeb.UrlRewriteModule, Arcs.CoopFurniture.TelesalesWeb" preCondition="managedHandler" />
  </modules>
  <handlers>
    <add name="AspNet" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" requireAccess="None" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
  </handlers>
  <validation validateIntegratedModeConfiguration="false" />
</system.web>

The site is running under classic rather than integrated pipeline mode.

Does anyone out there have any ideas? I suspect my configuration is wrong somewhere but I can't seem to find where.

Best Answer

This is a bit of a long shot, but have you tried actually making the configuration changes inside of IIS?

I know that the web.config way is supposed to be 100% foolproof, but I've seen a few things where it helps to just configure it in IIS to get it working correctly.

Related Topic