У меня есть этот вид:
@page
@model TreesOnMars.Pages.NewGameModel
@{
ViewData["Title"] = "New Game";
}
<h2>New Game</h2>
<form method="POST">
<table>
<tr>
<td><label asp-for="Name"></label></td>
<td><input type="text" asp-for="Name" /></td>
</tr>
</table>
</form>
<button type="submit" asp-route-data="@Model.Name">Create Game</button>
С этой моделью страницы:
[Authorize]
public class NewGameModel : PageModel
{
public void OnGet()
{
}
public void OnPost()
{
Redirect($"Game/{Name}");
}
/// <summary>
/// The name of the game to create.
/// </summary>
public string Name { get; }
}
Но когда я нажимаю кнопку отправки, ничего не происходит - ни методы OnGet, ни OnPost не вызываются. Что тут происходит? Как я могу сделать кнопку отправки вызова OnPost ()?