0

why can't I read the error message in AngularJS from the following code

ModelState.AddModelError("field", "error");

return BadRequest(ModelState);

or

return BadRequest("error message");
return Content(System.Net.HttpStatusCode.BadRequest, new { field = "error"});

all I get when I catch that error is

    { 
        data: "Bad request", 
        status: 400, headers: ..... , 
        config: //POST method config, 
        statusText: "Bad Request" 
    }
Tony
  • 12,405
  • 36
  • 126
  • 226

1 Answers1

0

ok, I saw I had the config line:

<httpErrors errorMode="myMode" existingResponse="Replace">

and it should be

<httpErrors errorMode="myMode" existingResponse="PassThrough">
Tony
  • 12,405
  • 36
  • 126
  • 226