Iis – any url rewrite rule causes internal server error on iis7

iisredirectrewrite

I have iis7 on a Windows server 2008 and iis url rewrite module 2 installed.

Any url rewrite rule (in my case a simple canonical domain name rule) causes the webapp to return an error 500.

In my case I have 4 domains mapped to the same web app and want to redirect 3 of the alternative domains to the main domain, after setting the rule any request to the webapp for those domains returns an error, the one domain of the web app that wasn't affected by the rule remains ok.

I did repair to the iis url rewrite module but the problem continues..

If I turn off the custom errors I see the problem is on my web app, however if don't have any rewrite/redirect rules I donit get any error. Probably the rewrite is messing with something in the pipeline..

The stacktrace is the following:

[NullReferenceException: Object reference not set to an instance of an object.]
   Glimpse.Core.Extensions.DataStoreExtensions.Get(IDataStore store, String key) +35
   Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context) +50
   Castle.DynamicProxy.AbstractInvocation.Proceed() +595
   Castle.Proxies.IDependencyResolverProxy.GetService(Type serviceType) +177
   System.Web.Mvc.DependencyResolverExtensions.GetService(IDependencyResolver resolver) +61
   xxxxx.NHibernateSessionPerRequestModule.<Init>b__1(Object param0, EventArgs param1) +40
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165

Shouldn't the url rewrite/redirect end the processing of the request and submit the response??

Best Answer

I'm not sure about your error, but since no one else has tried an answer, and you have a problem to solve, I'll suggest a different way to accomplish your goal.

Leave your main app only answering at the name you want people to use. Add a second web app that answers to the 3 names you want redirected. Configure this site to forward traffic to the main domain.