Angular2 to REST WebApi CORS issue

后端 未结 10 1968
太阳男子
太阳男子 2020-12-15 06:50

I\'m using an angular2 front end and WebApi backend. The webapi is CORS enabled

var cors = new EnableCorsAttribute(\"*\", \"*\", \"*\");
GlobalConfiguration.         


        
10条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 07:08

    Please follow the step for CROS ISSUE fixes in WEB API:

    1. Enabling CORS required Headers in the Application. i.e. in “Application_BeginRequest” Method in “Global.asax” file for simple requests.

    2. Placing the below code in “web.config” file helped in CORS issue for preflight requests

      
                
                  
                  
                  
                
              
      

    Reference: https://docs.microsoft.com/en-us/aspnet/web-api/overview/security/enabling-cross-origin-requests-in-web-api#enable-cors

提交回复
热议问题