如何使用401返回错误消息?

时间:2017-11-01 14:38:48

标签: asp.net-core-2.0

这似乎每隔一年就会发生变化。

var msg = new HttpResponseMessage(HttpStatusCode.Unauthorized) { ReasonPhrase = "Terms not accepted." };

throw new HttpResponseException(msg);

这里的问题是框架不知道HttpResponseException是什么。

那么,现在做什么呢?

1 个答案:

答案 0 :(得分:0)

Halleluyah!

   return StatusCode(401, "Hello World!");
相关问题