Issue with POSTS when deploying MVC app to Azure App Service

I have a completed web app that runs perfectly fine on localhost. Every endpoint is hit correctly and goes off without a hitch. BUT, when I published this web app on to an Azure App Service, none of the POST calls are hit. When I observe what's happening inside of the network tab I see 404's. This appears to only be happening with POSTs and not GETs. GETs seem to be working fine.

Also, it is probably important to note that I am using Razor page handlers to trigger the actions. As you can see, I have a Razor page handler asp-page-handler="Login" that should be triggering an action in the code behind called OnPostLogin.


 <form class="text-center p-5" method="post">
     <div asp-validation-summary="All" class="error-message"></div>
     <input type="text" id="defaultLoginFormEmail" class="form-control mb-4" placeholder="UserName" asp-for="@Model.UserName">
     <input type="password" id="defaultLoginFormPassword" class="form-control mb-4" placeholder="Password" asp-for="@Model.Password">
     <button class="btn btn-block my-4" type="submit" asp-page-handler="Login">Sign in</button>

Here is the code behind method for this Razor page:

public async Task<IActionResult> OnPostLogin()
            var result = await _signInManager.PasswordSignInAsync(Input.UserName, Input.Password, false, false);
            // if successful login
            else if (result.Succeeded)

            // if unsuccessful
            else return RedirectToPage("/Account/LoginError");

            return Page();

It doesn't even appear to be getting hit when I click the login button. Bear in mind that this isn't just an issue with this specific POST. It is an issue with ALL of the POSTS (only on azure apps service, not on localhost).

Thank you in advance for your willingness to help!

Read more here:

Content Attribution

This content was originally published by Andrew Smith at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: