Answer the question
In order to leave comments, you need to log in
How to disable CORS in C# .net WEB API?
How to disable CORS in C# .net WEB API?
Answer the question
In order to leave comments, you need to log in
It is necessary to register CORS policy in services. Something like:
services.AddCors(opt =>
{
opt.AddPolicy("CorsPolicy", policy =>
{
policy.AllowAnyMethod().AllowAnyHeader().WithOrigins("API_ADDRESS");
});
});
Then in the Configure method after app.UseRouting(); write
app.UseCors("CorsPolicy");
For aspnet core: https://docs.microsoft.com/en-us/aspnet/core/secur...
For aspnet webapi: https://docs.microsoft.com/en-us/aspnet/web-api/ ov...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question