In my MVC application, when a POST request is sent to the server (via jQuery) and a validation error occurs, a 400 Bad Request is returned, as intended:
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: application/json; charset=utf-8
Server: Microsoft-IIS/8.5
X-AspNet-Version: 4.0.30319
Date: Thu, 26 Feb 2015 08:35:50 GMT
Content-Length: 174
{"ReturnValue":null,"Results":[{"Message":"The xyz field is required.","ErrorNumber":123,"Severity":1}]}
This works as intended on my local machine. However when I deploy the application to the server, the response for the exact same request looks different:
HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: text/html
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
Date: Thu, 26 Feb 2015 08:37:01 GMT
Content-Length: 24
Invalid Request
Note that the content type is text/html
, and the response body doesn't contain JSON anymore.
What could be the cause of this? I would appreciate a pointer where to start debugging.