CORS in .NET Core

前端 未结 10 1076
失恋的感觉
失恋的感觉 2020-12-04 23:30

I am trying to enable CORS in .NET Core in this way:

    public IConfigurationRoot Configuration { get; }

    public void ConfigureServices(IServiceCollecti         


        
10条回答
  •  自闭症患者
    2020-12-05 00:00

    I encountered CORS issues in my application. I felt that I properly implemented the logic but was still getting presented with Access-Control-Allow-Origin 403 Error. I tried every setting mentioned above but nothing worked.

    I later discovered that my issue wasn't CORS related. I implemented a custom attribute

    [Route("v1/[Controller]")]
    [ServiceFilter(typeof(MyCustomFilterAttribute))]
    public class MySpecialListsController 
    

    Calls made to the controller were properly making it to the method OnActionExecuting

    public override void OnActionExecuting(ActionExecutingContext context)
    

    The logic within the filter was throwing an exception and was presented as a CORS 403 error.

提交回复
热议问题