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??


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.

  • i used a workaround on an action filter to handle this redirect, but i will need more rules and dont want to use this way for the others – rjlopes Apr 29 '15 at 12:05

Are you creating the redirect rules in the GUI, or by editing web.config directly? It might be that your web.config has an error in it somewhere. Try turning custom errors off so you can see the detailed error message, it should help you track the problem down.

Find this line in your web.config and uncomment it;

<customErrors mode="off"/>

If you're making changes in the GUI then try posting a screenshot of your current rules, someone might spot the problem.

  • web.config is fine because the app runs without eny issue. i am using the gui but if i use the web.config directly using the system.webserver section the problem is the same – rjlopes Apr 28 '15 at 13:39
  • Well, it's not fine if you're getting an error 500... Try turning on detailed error reporting (turning off custom error reporting) as I suggested and see what it says. Post the error here if you're not sure. By the way, I've edited my post to show the customErrors web.config snippet - hadn't realised it hadn't rendered properly...! – Steve365 Apr 28 '15 at 13:47
  • i updated the question with this info – rjlopes Apr 29 '15 at 12:06
  • @rjlopes Your question edit isn't showing to me... – Steve365 Apr 29 '15 at 12:09
  • i was just formatting the response and it took me a little more than it was supposed to, sorry. – rjlopes Apr 29 '15 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.