Best way to abort/cancel action and response from ActionFilter
Setting the response will mean the action doesn’t get called. public override void OnActionExecuting(HttpActionContext actionContext) { actionContext.Response = new HttpResponseMessage(HttpStatusCode.Unauthorized); } As other answers have said, though, authentication should be done with an AuthorizeAttribute (Docs for Web.API or for MVC).