我正在尝试设置一个简单的登录html页面,其操作被发送到我的另一个网站上的mvc控制器.我没有问题设置页面来做帖子,在mvc控制器中我有我的方法来读取表单帖子.问题是我没有在表单集合中看到html表单中的字段.
在mvc控制器方法中读取表单帖需要做些什么特别的事情,如果是这样的话是什么?
这是我页面中的表单操作标记
<form action="http://reconciliation-local.sidw.com/login/launch" method="post">
User Name <input type="text" id="username"/><br/>
Password <input type="text" id="password"/>
<input type="submit" value="launch"/>
</form>
Run Code Online (Sandbox Code Playgroud)
控制器方法
[HttpPost]
public ActionResult launch(FormCollection fc)
{
foreach (string fd in fc)
{
ViewData[fd] = fc[fd];
}
return View();
}
Run Code Online (Sandbox Code Playgroud)
当我单步执行控制器方法代码时,我在formcollection参数中没有看到任何内容.