I am creating a WebApi controller and I am trying to use an HttpPost request to send a new user for registration. This works fine on my local host, but when I publish it on Azure, I get a 405 method that does not allow an error with the message: "The requested resource does not support the" GET "http method.
I use a postman to check actions, so I used the generation code to see a query that looks like this:
POST /api/account/register/student HTTP/1.1 Host: www.l3cture.com Content-Type: application/json Cache-Control: no-cache Postman-Token: 27c1b2ab-96ad-4a99-b271-4030402768e7
Therefore, I can clearly see that the request is POST. And the following controller action code with its attributes (I have currently simplified it so that no models are sent, and the same behavior happens)
[HttpPost] [Route("register/student")] [AllowAnonymous] public async Task<IHttpActionResult> PostStudent() {
I checked the attribute namespace and this is System.Web.Http, so it is not confused with the MVC namespace.
Interestingly, when I change the HttpGet and POST method to it using the mail manager, I get the status 200. In almost the same way as the HttpPost requests, all my calls are treated as HttpGet by my controller.
I used HttpPut and HttpDelete in other places, and they all work fine.
I'm not sure how to solve this problem, and it was interesting if anyone has any ideas? Please let me know if I need to post more code for clarification.
Thank you in advance
source share