How to get MVC action to return 404

后端 未结 12 1799
日久生厌
日久生厌 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:16

    There are multiple ways to do it,

    1. You are right in common aspx code it can be assigned in your specified way
    2. throw new HttpException(404, "Some description");

提交回复
热议问题