Last post May 12, 2021 07:45 PM by PatriceSc
May 09, 2021 05:36 AM|alvinoo|LINK
When I use a PUT request, the following is shown.
Does it mean that put request is enabled and how can I disable it?
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<hr><p>HTTP Error 411. The request must be chunked or have a content length.</p>
May 09, 2021 10:22 AM|mgebhard|LINK
The error state the content length header is missing in the HTTP request. The 4XX HTTP statuses are malformed request errors. The community can help if you share the code that caused the error.
May 09, 2021 11:38 AM|PatriceSc|LINK
For now you have a
411 Length Required - HTTP | MDN (mozilla.org) . Your intent is unclear. Do you try to send a chunked request or this is a test and you really just want to disable PUT requests ?
Edit: if you really want to disable PUT a possible option could be to use filtering as shown at
Verbs <verbs> | Microsoft Docs
May 12, 2021 06:58 AM|alvinoo|LINK
Yes, I just want to disable the put request. It should show method not allowed right? instead of 411
May 12, 2021 07:45 PM|PatriceSc|LINK
You are using ASP.NET 4.x or Core? This is an MVC or an API controller? Some more context could help.
Generally, you can use attributes such as [HttpPost], [HttpPut] and so on to tell explicitly which that an action should respond to a given http verb. See earlier if you want to disable the PUT verb at the IIS level.
Edit: I tested an [ApiController] with ASP.NET Core 5.x and it does show a 405 status code.