I am attempting to debug, what I think is, an IIS rewrite issue.
I am hosting multiple sites on a single IIS server which is acting as a proxy to Kestrel hosts behind the scenes. That is all working correctly and I haven't been having any issues there.
The issue I am running into is when any of my sites do a return Redirect("http://www.someotherurl.com/")
via ASP.NET MVC, the base URL is always rewritten to the URL of my site - this is true even if the URL is completely external to my URL.
If I run the site separately, not within the IIS proxy, the redirect works as I expect, so I know that it's something within IIS.
As far as rules, I have no outbound rules at all right now. For inbound rules, I have (for each one of my sites):
- HTTP to HTTPS redirect rule.
- A rewrite rule which takes the URLs and rewrites the URL to http://127.0.0.1:port so that the self-hosted services can handle the request appropriately. There is an individual rule per site.
I am very stumped at this point because I don't see any other way redirects would not go to the actual URL that I provide, but IIS seems to be doing something mysterious.
More Information
- Request comes in for www.example.net/Documents.
- Rule rewrites the URL to 127.0.0.1:port/Documents based on the incoming URL.
- Endpoint handles the request.
- A redirect response is sent.
- The Base URL is converted back to www.example.com no matter what - even if the redirect is to a different domain. I believe this is where the problem is occurring. It seems like IIS does this by default. I'm not sure, however.