I’m back in the Optimizely sphere after working on vanilla .NET applications for a while, and ran into a weird 301 permanent redirect happening when calling an API endpoint in an Optimizely 11 website.
A call to the endpoint would often produce the expected JSON response, but once in a while we would instead get an HTML response showing the Contact us page.
I found that the redirect happens inside an implementation of the IPartialRouter interface, in the RoutePartial method. This class makes it possible to change the behaviour of the default routing in Optimizely.
The reason for this was seems to have been a need to redirect to the contact us page when trying to surf directly to a specific type of content. It would work just fine for the intended purpose except that everytime someone calls the IUrlResolver method Route, the current response would be rewritten into the 301, as it makes use of the RoutePartial method to find the relevant IContent.