我有一个带有单个输入和按钮的Ajax表单。提交时,表单应该只将输入的值发布到一个操作方法。我的表单正确地发布到了User控制器的Log方法,但完成后,页面重定向到/User/Log。
我该如何避免这种情况发生?
<% using (Ajax.BeginForm("Log", "User", null, new AjaxOptions {HttpMethod = "POST" }))
{%>
Please enter the username:
<%= Html.TextBox("Username", "")%>
<input type="submit" />
<% } %>
这是操作方法:
public class UserController : Controller
{
[AcceptVerbs(HttpVerbs.Post)]
public void ForgotPassword(FormCollection collection)
{
string username = collection["Username"];
//TODO: some work
}
}
感谢您,Keith。