【发布时间】:2016-06-17 00:17:27
【问题描述】:
在 VS Code 中使用 .NET Core RC2 我有以下 HTML
<form asp-controller="Home" asp-action="Connexion" method="post">
<div class="col-md-4 input-group">
<input type="text" id="password" class="form-control" placeholder="Mot de passe">
<span class="input-group-btn">
<button class="btn btn-secondary" type="submit">Envoyer</button>
</span>
</div>
</form>
还有一个控制器
[HttpPost("/Connexion")]
public IActionResult Connexion([FromBody] string password)
{
return View();
}
提交表单时,它在方法中命中了我的断点,但密码参数为空。我做错了什么?
【问题讨论】:
-
浏览器使用输入控件的
name属性向服务器提交数据。id属性是客户端的东西。
标签: c# asp.net-mvc .net-core-rc2