【发布时间】:2021-03-07 19:34:30
【问题描述】:
我在剃须刀页面上有以下表格:
<form method="post">
<table>
<tr>
<td style="padding-bottom: 10px;" class="login-entry">User Name</td>
<td style="padding-bottom: 10px;"><input type="text" asp-for="LoginName" class="logins" autocomplete="off" /></td>
</tr>
<tr>
<td style="padding-bottom: 10px;" class="login-entry">Password</td>
<td style="padding-bottom: 10px;"><input type="password" asp-for="Password" class="logins" /></td>
</tr>
<tr>
<td colspan="2" style="text-align:right;"><input type="submit" value="login" /></td>
</tr>
</table>
</form>
然后,在我的 PageModel 中,我有两个属性和 OnPostAsync:
public string LoginName { get; set; }
public string Password { get; set; }
public async Task<IActionResult> OnPostAsync()
{
// Login code here
}
问题是当我调试页面时,输入用户名和密码,然后单击登录,在 OnPostAsync 方法中,属性 LoginName 和 Password 都是空的。
有没有人知道为什么这不起作用?或者,由于我是 Razor 页面的新手,至少有一种方法可以在它们不起作用时追踪这些东西?任何帮助将不胜感激。
【问题讨论】:
标签: c# asp.net-core asp.net-core-razor-pages