I have a Website (running angular) with a .net backend. I am experiencing an issue where I can make POST and GET requests successfully from domain https://example.net to domain https://example.net. However the moment I try to make a PUT request, it fails claiming that:
"No 'Access-Control-Allow-Origin' header is present on the requested resource."
In debugging, I have verified that the header is present on GET and POST requests.
In My Backend: Startup.cs:
app.UseCors(c => {
c.AllowAnyHeader();
c.AllowAnyMethod();
c.WithOrigins("https://example.net", "https://www.example.net");
});
The Controller:
[ApiController]
public class TestController : BaseController { //which derives from ControllerBase
[HttpPut]
[Route("api/[controller]")]
public async Task<IActionResult> TestMethod([FromBody] RequestData requestData) {
//...
}
//...
As far as I can tell, it should be working as intended.
Note:
I have also tried c.AllowAnyOrigin()