A 405 response means that a request reached a matching resource path, but its HTTP method is not supported there. The endpoint handler does not run. section 5.2.2 section 20.3.3
Check these common causes when a request returns 405:
- Use the HTTP verb assigned to the endpoint, such as GET, POST, PUT, or DELETE. section 5.2.2 section 20.3.3
- Verify the URL path carefully; a typo can produce 405 even when the intended verb is correct. section 5.2.2
- Match controller actions with attributes such as [HttpGet] and [HttpPost], or map the corresponding minimal API verb. section 20.3.3 section 5.2.2
A wrong verb
An endpoint mapped with MapGet("/person/{name}", handler) accepts GET requests. Sending POST to /person/Al matches the path but not the method, so the handler is skipped and the response is 405 Method Not Allowed. section 5.2.2
Table 5.1 The minimal API map endpoints and the corresponding HTML verbs (view table figure)
| Fetch data only; no modification of state. May be safe to cache. |
||
Use the endpoint map to compare HTTP verbs with their intended operations, including fetching, creating, replacing, modifying, and deleting resources. section 5.2.2
