我有一个 AJAX 表单和对应于该表单的操作方法。我希望此表格保留 [授权]。
AJAX 形式:
@using (Ajax.BeginForm("Vote", "Rate", null ,
new AjaxOptions
{
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET",
OnFailure = "searchFailed",
LoadingElementId = "ajax-loader",
UpdateTargetId = "searchresults",
},new { id = "voteForm" }))
{
<input type="radio" name="Stars" value="1">
<input type="radio" name="Stars" value="2">
<input type="radio" name="Stars" value="3">
<input type="submit" value="Vote" />
}
和授权行动
[Authorize]
public ActionResult Vote(Rate rate)
{
if (ModelState.IsValid)
{
db.Rates.Add(rate);
db.SaveChanges();
}
return PartialView("_Vote");
}
当我单击提交按钮时,登录页面显示在 UpdateTargetId(searchresults) 中,但它需要在新窗口中显示。