405 METHOD NOT ALLOWED - POST in EDIT

Viewed 57

Im new to coding Im working in a project (CRUD - asp.net). My setup was SQL - API - MVC

So this is what happened: CRUD is working when I tried it in localhost, but upon deploying it in web app service, I got a problem with EDIT mode only.

GET is working (it was able to retrieve the data) POST isn't (when im saving it error is found)

Upon checking the debug mode status code of POST in EDIT says 405 Method not Allowed

My question is why my CREATE functionality works with get and post but in EDIT im having an issue. What makes the restriction.

Note: CREATE and DELETE are workkng.

Thank you!

1 Answers

Cuz your action HttpMethod attribute is not matching the request http method.

for example if this is your action:

[HttpPut]
public async Task<IActionResult> edit()
{
}

then your request must use http Put method to call this action.

Related