2

Problem

We currently have two ASP.NET MVC projects being served up from a Windows Server 2012 R2 with IIS 8.5 like so:

  • foo hosted on server.com/foo
  • bar hosted on server.com/bar

However, the code of these projects is nearly identical so we're in the process of consolidating them. Ideally, we'd have

  • common hosted on server.com/common (which would only be used internally)
  • IIS rewrite rule ^foo(.*)$common{R:1} so it appears to be hosted on server.com/foo
  • IIS rewrite rule ^bar(.*)$common{R:1} so it appears to be hosted on server.com/bar

We've set up the new common project and it's working fine on server.com/common, however, when we enabled the rewrite rules, anything trying to navigate to server.com/foo or /bar will produce a 403 error, specifically:

403 - Forbidden: Access is denied

Troubleshooting

I'm pretty sure this is not an issue with my pattern/replacement strings, because if I change the rule type to Redirect, it produces the desired destination URL.

If I create a IIS rewrite rule ^common/test(.*)$common{R:1} then the common code runs correctly, but ^common-test(.*)$common{R:1} fails, so there's something preventing common from being served from any URL other than /common.

What's confusing here is that there is another application which does a similar thing with /baz and /qux being rewritten to a shared application, /other. If I point ^foo(.*)$other{R:1} it works fine (though of course, it executes the wrong application code). I'm unable to identify any other relevant differences between these two applications that would cause this. In fact, I copied nearly all the Web.config file from other and still saw the same behavior.

I've also exhausted these other potential solutions:

What else could be causing this? I'd appreciate any pointers.

  • 1
    Hi, does the iis error log show anything usefull for the 403 error ? – yagmoth555 Jun 6 '19 at 17:19
  • @yagmoth555 None that I've been able to find. This server hosts a large number of applications and the logs folder doesn't make it obvious which log file is for which application. I enabled log rewritten URL hoping I could grep for it, but no such luck. If it is creating logs, I haven't found them. – p.s.w.g Jun 6 '19 at 17:43
1

After digging around a bit more and conferring again with the developers behind other, I think we've figured out this issue.

Basically, the site hosting server.com and all the applications under it that will be participating in the rewrite (common, as well as foo and bar until we are ready to delete them) need to be running in the same IIS app pool.

I've adjusted our deployment process to account for this. We use Octopus, so it boiled down to just changing one variable in each project. For future readers, your process is probably different, but just in case, hopefully this helps someone else:

Project Variables

| improve this answer | |

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.