123456789101112131415161718192021222324252627282930 |
- 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", "POST");
- filterContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "x-requested-with,content-type");
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- base.OnActionExecuting(filterContext);
- }
- }
- }
|