C# WebApi 权限过滤器
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"); }
浙公网安备 33010602011771号