using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace EMIS.Web.Controls.Filters { public class ServiceControllerAttribute : ActionFilterAttribute { public override void OnActionExecuting(ActionExecutingContext filterContext) { if (filterContext.Controller.GetType().Namespace.StartsWith("EMIS.Web.ApiControllers")) { try { filterContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); filterContext.HttpContext.Response.AddHeader("Access-Control-Allow-Methods", "OPTIONS,POST,GET"); filterContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type"); } catch (Exception ex) { throw ex; } } base.OnActionExecuting(filterContext); } } }