how to return json error msg in asp.net web api?

后端 未结 5 1764
没有蜡笔的小新
没有蜡笔的小新 2021-02-03 21:14

I would like to return a json errormessage but at the moment in fiddler I cannot see this in the json panel:

string error = \"An error just happened\";
JsonResul         


        
5条回答
  •  忘掉有多难
    2021-02-03 22:01

    JsonResult is a MVC concept. It does not work in Web API. One way to explicitly return json content is to use the class I created in this answer https://stackoverflow.com/a/20504951/6819

提交回复
热议问题