The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CORSActionFilter.cs 630B

123456789101112131415161718192021222324
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. namespace Teknik.Filters
  7. {
  8. public class CORSActionFilter : ActionFilterAttribute
  9. {
  10. public override void OnActionExecuting(ActionExecutingContext filterContext)
  11. {
  12. if (filterContext.HttpContext.Request.HttpMethod == "OPTIONS")
  13. {
  14. // do nothing let IIS deal with reply!
  15. filterContext.Result = new EmptyResult();
  16. }
  17. else
  18. {
  19. base.OnActionExecuting(filterContext);
  20. }
  21. }
  22. }
  23. }