I am deadly stuck in enabling CORS in my web application. My project is not MVC project and I started the project as empty web application. My front-end is HTML5 and AngularJS and calling service layer (Rest APIs) for all back-end calls. My front-end is calling the Rest APIs deployed separately. I have gone through multiple post and followed posts and applied code and configuration changes but nothing worked. I have done the following:
- Installed Microsoft AspNetCore package using NuGet Package Manager.
- After installing AspNetCore package I couldn't see any WebApiConfig.cs, so I created manually and added the code, but couldn't see any breakpoint coming to this class.
- I added Global.asax file so as to call the WebApiConfig.cs but didn't work as EnableCors method has different signatures, so complile time error.
- Web.config changes in system.webserver :
<httpProtocol>
<!-- THESE HEADERS ARE IMPORTANT TO WORK WITH CORS -->
<!--
<customHeaders>
<add name="Access-Control-Allow-Origin" value="http://localhost:5000" />
<add name="Access-Control-Allow-Methods" value="POST, PUT, DELETE, GET, OPTIONS" />
<add name="Access-Control-Allow-Headers" value="content-Type, accept, origin, X-Requested-With, Authorization, name" />
<add name="Access-Control-Allow-Credentials" value="true" />
</customHeaders>
-->
</httpProtocol>
Looking forward for the expert advise on what wrong am doing.
Aucun commentaire:
Enregistrer un commentaire