当我使用此控制器注销时:
public class LogOffController : Controller
{
public ActionResult Index()
{
FormsAuthentication.SignOut();
return View();
}
}
呈现的页面不知道我已注销,并且在剃须刀页面的一部分中我显示用户:
@if (Request.IsAuthenticated)
{
<text>Welcome <strong>@Profile.GetPropertyValue("FullName")</strong>
@if (User.IsInRole("Administrator"))
{
@Html.ActionLink("(Administrator)", "Index", "Administration")
}
[ @Html.ActionLink("Log Off", "Index", "LogOff") ]</text>
}
else
{
@Html.ActionLink("Login", "Index", "Login")
}
这仍然显示用户名和管理员角色,就像他们仍然登录一样。我导航到的下一页是正确的。