I have a simple model as that has 2 fields and with the following put method, i'm tring to update it in the db. Everymethod including delete works, however put method always returns a 405 error in Postman. (tried WebDAV solutions as well.) What am I missing here?

PUT METHOD:
{
"MasterId":1,
"MasterName":"Test"
}
Action
[HttpPut("{id:int}")]
public async Task<IActionResult> PutMaster(int id, Master master)
{
if (id != master.MasterId)
{
return BadRequest();
}
//...some code
return NoContent();
}
If your application is being hosted under IIS, running API in ASP.NET Core, include this line in the Web.Config file
<configuration>
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
</system.webServer>
</configuration>
If you are using IIS to run your application and have WebDav module, that can be an issue. For some strange reason WebDav does not allow PUT.
I just uninstalled it, and it helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With