How To Enable Cross Origin Requests In ASP .NET CORE
Answers (1)
Add AnswerAdd the below code Startup.cs
services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder .SetIsOriginAllowed((host) => true) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); }); app.UseCors("CorsPolicy");
just add this line on your controller.
[Route("api/[controller]")] ApiController] [EnableCors("CorsPolicy")] public class BaseController : ControllerBase { }
Hope it helps you.