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
Alternative to MstfAsan's answer is to use:
return Forbid();
It is a method on the controller base class that does the same thing.
Or
return StatusCode(403);
If you want to return a message, then you must use StatusCode.
StatusCode