Skip to content

Instantly share code, notes, and snippets.

@vongohren
Created September 1, 2014 08:16
Show Gist options
  • Save vongohren/0d365a2812287edfd22c to your computer and use it in GitHub Desktop.
Save vongohren/0d365a2812287edfd22c to your computer and use it in GitHub Desktop.
using System.Web.Mvc;
namespace BEKK_Radar.Web.Helpers.CustomFilters
{
public class CorsActionFilter : ActionFilterAttribute, IActionFilter
{
void IActionFilter.OnActionExecuting(ActionExecutingContext context)
{
if (context.HttpContext.Request.RequestType.Equals("POST")) return;
context.HttpContext.Response.AddHeader("Access-Control-Allow-Origin","*");
context.HttpContext.Response.AddHeader("Access-Control-Allow-Methods", "GET");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment