Hi Team,
I have created one basic web api to interact with the database.
I am calling this api using Angular application, due to CORS error i have added below line of code in Global.asax file.
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin","http://localhost:4200");
Now i can fetch my employee details using api however while adding new employee details again i am facing CORS error, as mentioned below.
Access to XMLHttpRequest at 'http://localhost:59571/api/Employee' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
I am new to both API and Angular 2 technologies, so please help me with solution.
What I have tried:
i have added below line of code in Global.asax file.
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin","http://localhost:4200");