I have a razor page with a form and multiple submit buttons. with each button I want to start a different Post action in my codebehind file. so this is in my cshtml page:
<form class="form" method="post" >
<input type="submit" value="Test1" formaction="Button1" />
<input type="submit" value="Test2" formaction="Button2" />
</form>
and this in my cshtml.cs file:
[HttpPost]
public IActionResult Button1(IFormCollection data)
{
//my code
}
[HttpPost]
public IActionResult Button2(IFormCollection data)
{
//my code
}
Unfortunately, this is not working. when I submit I get a 404 error:
This localhost page can’t be found No webpage was found for the web address: https://localhost:44366/Mutations/Button1 HTTP ERROR 404
The correct URL should be: https://localhost:44366/Mutations/Test
What am I doing wrong?