Friday, June 16, 2017

MVC controller action from JavaScript is returning 404

In developing front-end logic to call MVC controller actions (with Sitecore context), I noticed that the calls were returning a 404 from the delivery servers and not management servers.

The URL of the AJAX request was:
url: "/Accounts/Register"
Inside the console, that request appeared as follows

The request on delivery server returned a 404

The request on the management server worked
Investigation lead to the result that URLs on the delivery server were all being redirected to lowercase URLs. Hence the initiator for the AJAX call changing between servers. MVC controllers will work with both uppercase and lowercase URLs, so the problem was not likely on that end. What appeared to be happening was that the redirect was messing up the call and requesting it as a standard page (hence the 404 response, which was actually returning the IIS 404 page).

Changing the request URL in AJAX to be lowercase fixed the issue.
url: "/Accounts/Register"

No comments:

Post a Comment