How to enable CORS in ASP.NET Core

前端 未结 12 783
无人及你
无人及你 2020-11-22 14:11

I am trying to enable cross origin resources sharing on my ASP.NET Core Web API, but I am stuck.

The EnableCors attribute accepts policyName

12条回答
  •  执笔经年
    2020-11-22 14:39

    If you are hosting on IIS, one possible reason is you are getting this is because IIS is blocking OPTIONS verb. I spent almost an hour because of this:

    One telltale indication is you are getting 404 error during OPTIONS request.

    To fix this, you need to explicitly tell IIS not to block OPTIONS request.

    Go to Request Filtering:

    Make sure OPTIONS is allowed:

    Or, just create a web.config with the following setting:

    
        
            
                
                    
                    
                
            
        
    
    

提交回复
热议问题