How to return a specific status code and no contents from Controller?

前端 未结 5 1002
谎友^
谎友^ 2020-11-28 02:29

I want the example controller below to return a status code 418 with no contents. Setting the status code is easy enough but then it seems like there is something that needs

5条回答
  •  借酒劲吻你
    2020-11-28 03:12

    If anyone wants to do this with a IHttpActionResult may be in a Web API project, Below might be helpful.

    // GET: api/Default/
    public IHttpActionResult Get()
    {
        //return Ok();//200
        //return StatusCode(HttpStatusCode.Accepted);//202
        //return BadRequest();//400
        //return InternalServerError();//500
        //return Unauthorized();//401
        return Ok();
    }
    

提交回复
热议问题