How to get MVC action to return 404

后端 未结 12 1803
日久生厌
日久生厌 2020-12-23 02:53

I have an action that takes in a string that is used to retrieve some data. If this string results in no data being returned (maybe because it has been deleted), I want to r

12条回答
  •  借酒劲吻你
    2020-12-23 03:06

    You can also do:

            if (response.Data.IsPresent == false)
            {
                return StatusCode(HttpStatusCode.NoContent);
            }
    

提交回复
热议问题