private AuthorizationContext GetAuthorizationContext( FilterDescriptor[] filterDescriptors, RequestHeaders headers = null, bool isPreflight = false) { // HttpContext var httpContext = new DefaultHttpContext(); if (headers != null) { httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestHeaders, headers.Headers.Split(',')); httpContext.Request.Headers.Add(CorsConstants.AccessControlRequestMethod, new[] { headers.Method }); httpContext.Request.Headers.Add(CorsConstants.AccessControlExposeHeaders, headers.ExposedHeaders.Split(',')); httpContext.Request.Headers.Add(CorsConstants.Origin, new[] { headers.Origin }); } var method = isPreflight ? CorsConstants.PreflightHttpMethod : "GET"; httpContext.Request.Method = method; // AuthorizationContext var actionContext = new ActionContext( httpContext: httpContext, routeData: new RouteData(), actionDescriptor: new ActionDescriptor() { FilterDescriptors = filterDescriptors }); var authorizationContext = new AuthorizationContext( actionContext, filterDescriptors.Select(filter => filter.Filter).ToList() ); return authorizationContext; }