我目前正在尝试解决我的网络应用程序注销的问题,但是登录页面却给我一个问题;
Child actions are not allowed to perform redirect actions.
这是由调用渲染操作的行
引起的Html.RenderAction("MessageBoard", "Home");
我认为我可以简单地更改注销以返回另一个视图(包含任何渲染操作部分),只是向用户提供他们已注销的通知。
所以目前在我的帐户控制器中我有
private IAuthenticationManager AuthenticationManager
{
get
{
return HttpContext.GetOwinContext().Authentication;
}
}
[HttpPost]
[ValidateAntiForgeryToken]
public virtual ActionResult LogOff()
{
AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
// doesnt hit below line as the signout seems to do all the work
// and redirects back to the login causing issue of child error message
return RedirectToAction("LogOff");
}
// Trying to get the signout to call this method after logoff
// using RedirectToAction in HTTP Post version.
public virtual ActionResult Logoff()
{
return View();
}
其他人遇到过这个问题,或者有更好的方法来克服我的缺点:)。
干杯