У меня есть конечная точка контроллера API, например:
public IHttpActionResult AddItem([FromUri] string name)
{
try
{
// call method
return this.Ok();
}
catch (MyException1 e)
{
return this.NotFound();
}
catch (MyException2 e)
{
return this.Content(HttpStatusCode.Conflict, e.Message);
}
}
Это вернет строку в теле, например "here is your error msg"
, есть ли способ вернуть JSON с 'Content'?
Например,
{
"message": "here is your error msg"
}