【发布时间】:2016-12-28 18:14:11
【问题描述】:
//Here is my View
@using
(Html.BeginForm("SearchUser", "User", FormMethod.Get))
{
<input type="text" id="keyText">
<input type="submit" value="Search" class="btn btn-success btn-lg" />
}
在我的控制器中,我有一个 SearchUser 方法 -
[HttpGet]
public async Task<IActionResult> SearchUser ([FromQuery] string keyText)
{
SearchUsersCommandAsync command = new SearchUsersCommandAsync
{
Key = keyText
};
var response = await new SearchUsersHandler(_db).Handle(command);
return View("Detail", response);
}
但是,当我收到请求 KeyText 时始终为空。我在这里做错了什么?
【问题讨论】:
-
您的输入需要
name属性 -name="keyText"才能将其值发送到控制器
标签: asp.net asp.net-mvc-3 asp.net-mvc-4 razor