我有这个链接
@Ajax.ActionLink("comment", "CreateDebateComment", new { id = Model.DebateID}, new AjaxOptions
{
UpdateTargetId = "comment-entry-box",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET"
});
这会触发控制器
[Authorize]
public PartialViewResult CreateDebateComment(int id)
{
DebateIDForComment = id;
return PartialView("_CreateDebateCommentPartial");
}
如果用户没有登录,他们将被重定向到LogOn页面,但它会在comment-entry-box div中加载,而不是重定向到登录页面。
我还尝试了这个变体。
public PartialViewResult CreateDebateComment(int id)
{
if (!User.Identity.IsAuthenticated)
{
RedirectToAction("LogOn", "Account");
}
DebateIDForComment = id;
return PartialView("_CreateDebateCommentPartial");
}
但是它不会重定向并且仍然会加载partialView。
有谁知道我如何让它按照我想要的方式工作? 我需要Log On页面正常加载,而不是在comment-entry-box中加载。
OutputCacheAttribute
来更改操作的缓存设置。 - moribvndvs