Hi @Amra Akmadžić,
405 Method Not Allowed means the url is correct but the request type is not correct.
From your code, two possible situations will cause such HTTP error.
Firstly, you backend code contains redirection. Be sure you contains an Index
action with [HttpGet]
in HomeController.
Secondly, you define [Route]
attribute in your MVC Controller, Attribute routes are processed first, and conventional routes are processed afterward. This will cause the issue the form action in your frontend is always /login
instead of /account/login
. Then you can see the form send Post request to /login
which will receive 405 HTTP Error.
To resolve this, ensure that both the GET and POST methods share the same route:
[HttpPost]
[Route("login")]
public async Task<IActionResult> Login(LoginViewModel model)
{
Ensure that the form in your Razor view uses the correct action
and method
attributes:
<form asp-action="Login" asp-controller="Account" method="post">
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Rena