[英]How do I return NotFound() IHttpActionResult with an error message or exception?
[英]How can I display the Ok () message from the IHttpActionResult in c #?
I am new to the area of api rest in c #, currently develop an Api rest, which is the following:
我正在使用 Ok () 方法返回查询的响应 200,但是如何将该答案集成到我的 Json 中?
[HttpGet]
public async Task<IHttpActionResult> Get(int _IdCanal, int _TipoAvance)
{
var lista_coutas = await _conexion.GetCuotas(_IdCanal, _TipoAvance);
if (lista_coutas == null)
{
return NotFound();
}
return Ok(lista_coutas);
}
它返回以下 Json:
{
"Cuotas": [
{
"opcion": 1,
"cuota": 12
},
{
"opcion": 2,
"cuota": 10
},
{
"opcion": 3,
"cuota": 8
},
{
"opcion": 4,
"cuota": 6
},
{
"opcion": 5,
"cuota": 5
},
{
"opcion": 6,
"cuota": 3
}
}
我正在使用 Ok () 方法返回查询的响应 200,但是如何将该答案集成到我的 Json 中?
如here所述,您可以返回一个HttpResponseMessage。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.