D
D
Denis Sokolov2021-10-10 11:11:56
.NET
Denis Sokolov, 2021-10-10 11:11:56

How to disable CORS in C# .net WEB API?

How to disable CORS in C# .net WEB API?
6162a04ad5696269780631.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Karabanov, 2021-10-10
@karabanov

CORS for dummies: the history of origin, how to ...

Y
Yuri Shporkhun, 2021-10-14
@xJAYx

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");

V
Vasily Bannikov, 2021-10-10
@vabka

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 question

Ask a Question

731 491 924 answers to any question