【发布时间】:2014-03-14 07:03:22
【问题描述】:
为什么 Ajax.BeginForm 在提交后将我的页面重定向到新的空白页面?
我的控制器代码是:
[HttpPost]
public void ProductCommentAdd(int productId, string text)
{
//Do something
}
视图中的 Mvc ajax 调用是:
@using (Ajax.BeginForm("ProductCommentAdd", "Shop", new AjaxOptions() { HttpMethod = "POST"}))
{
<input type="hidden" value="@Model.ProductId" name="ProductId"/>
<textarea name="text"></textarea>
<input type="submit" value="Submit"
}
当我点击提交按钮时,我的页面重定向到新的空白页面。我该如何解决?
【问题讨论】:
-
你有“ProductCommentAdd”的愿景吗?
-
您确定页面中包含
unobtrusive.ajax.js文件吗?
标签: c# asp.net-mvc asp.net-ajax