我希望下面的示例控制器返回没有内容的状态代码418。设置状态码很容易,但是似乎需要做一些事情以发出请求结束的信号。在ASP.NET Core之前的MVC或WebForms中,这可能是Response.End()
对它的调用,但是在Response.End
不存在的ASP.NET Core中它如何工作?
public class ExampleController : Controller
{
[HttpGet][Route("/example/main")]
public IActionResult Main()
{
this.HttpContext.Response.StatusCode = 418; // I'm a teapot
// How to end the request?
// I don't actually want to return a view but perhaps the next
// line is required anyway?
return View();
}
}
there is no dedicated result for 418
Microsoft,这里严重缺少功能。