How to return 403 Forbidden response as IActionResult in ASP.NET Core

前端 未结 4 576
粉色の甜心
粉色の甜心 2020-12-28 13:28

I would like to return a 403 Forbidden to the client when trying to perform an invalid operation. What is the method I need to use?

I searched over the internet but

4条回答
  •  旧时难觅i
    2020-12-28 14:08

    You can use return new ForbidResult(); Class declaration is

    public class ForbidResult : ActionResult, IActionResult
    

    For more spesific usages visit https://docs.microsoft.com/en-us/aspnet/core/api/microsoft.aspnetcore.mvc.forbidresult

提交回复
热议问题