public override void OnActionExecuting(ActionExecutingContext filterContext) { if (mOnVerbs.HasFlag(HttpVerbs.Post)) { } else if (mOnVerbs.HasFlag(HttpVerbs.Get)) { } base.OnActionExecuting(filterContext); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { var currentVerb = filterContext.HttpContext.Request.HttpMethod; if (mOnVerbs.HasFlag(HttpVerbs.Post)) { } else if (mOnVerbs.HasFlag(HttpVerbs.Get)) { } base.OnActionExecuting(filterContext); }
public AuthenticatedCorsApiAttribute(HttpVerbs verbs) { _policy = new CorsPolicy { AllowAnyHeader = true, SupportsCredentials = true }; // Verbs are case sensitive if (verbs.HasFlag(HttpVerbs.Get)) { _policy.Methods.Add("GET"); } if (verbs.HasFlag(HttpVerbs.Post)) { _policy.Methods.Add("POST"); } if (verbs.HasFlag(HttpVerbs.Put)) { _policy.Methods.Add("PUT"); } if (verbs.HasFlag(HttpVerbs.Options)) { _policy.Methods.Add("OPTIONS"); } var origins = AppConfig.AllowedCorsOrigins; if (!string.IsNullOrEmpty(origins)) { if (origins != "*") { Array.ForEach(origins.Split(','), _policy.Origins.Add); } else { _policy.AllowAnyOrigin = true; } } }