protected override void HandleUnauthorizedRequest(HttpActionContext filterContext) { base.HandleUnauthorizedRequest(filterContext); var response = filterContext.Response = filterContext.Response ?? new HttpResponseMessage(); response.StatusCode = HttpStatusCode.Forbidden; var content = new { success = false, errs = new[] { "服务端拒绝访问:你没有权限,或者掉线了" } }; response.Content = new StringContent(Json.Encode(content), Encoding.UTF8, "application/json"); }
标签:WebApi,filterContext,C#,过滤器,new,权限,response From: https://www.cnblogs.com/work-code/p/16869058.html