Reputation: 95
I'm not receiving the expected Response Content on the client when the resource returns BadRequest.
[HttpGet]
[Route("Test", Name = "Test")]
public async Task<IHttpActionResult> Test()
{
var result = BadRequest("test");
return result;
}
On client (see hurl.it example below) I simply receive the string Bad Request in the body:
The response on the server seems to be fine:
It was working fine at some point (returning strings or ModelState in content) and recently we noticed this problem. I can't think of any recent change on server that could cause it.
It works neither locally nor when deployed on server.
It can be reproduced in any ApiController in the project.
return Ok("test"); works as expected.
Does anyone know what can cause this behavior?
Thank you!
Upvotes: 2
Views: 3243
Reputation: 10321
It is hard to tell what goes wrong.
Things you could check:
BundleConfig
, RouteConfig
, FilterConfig,
WebApiConfig`. Perhaps some custom settings did cause to give you bad request error while it might be a not found error.<CustomErrors>
that might redirect, or throw there own errors.After some comments, custom erros seemed to be the problem.
Upvotes: 1