Note that this is for an ApiController in MVC 4 although I think it shouldn’t change anything.
public class OAuthFilter : System.Web.Http.ActionFilterAttribute
{
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
{
if (checkVerified())
{
// How to raise a 401 or some other type of exception.
}
}
}
You can set the result property of the
HttpActionContext:you may probably just throw:
but I haven’t checked that one.