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 676B

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