私は現在、私たちのサイトでセッションタイムアウトを処理するためのアクションフィルタを追加してい:セッションタイムアウト後にSystem.Security.Principal.Identity.IsAuthenticatedを設定するもの
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public class SsoExpireFilterAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if(!(filterContext.Controller.GetType() == typeof(HomeController)
&& filterContext.ActionDescriptor.ActionName == MVC.Home.ActionNames.Index))
{
if(filterContext.ActionDescriptor.ActionName != MVC.Home.ActionNames.TimeoutRedirect.ToLower())
{
if (!Thread.CurrentPrincipal.Identity.IsAuthenticated)
{
if (filterContext.HttpContext.Request.IsAjaxRequest())
filterContext.Result = new JsonResult { Data = "_Logon_" };
else
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary
{
{"Controller", "Home"},
{"Action", "TimeoutRedirect"}
});
}
}
}
base.OnActionExecuting(filterContext);
}
}
私はそれがでヒットされている場合しかし、それは真の残っている、偽の次のタイムアウトが発生したようにPrincipal.Identity上にisAuthenticatedフラグを期待していますアクションフィルタ(私はGlobal.asaxのSession_Endにブレークポイントを置いたので、セッションがタイムアウトしたことを知っています。これが最初にヒットします)。
私たちのサイトの認証は、企業標準の「シングルサインオン」DLLによって処理されるため、別の認証タイムアウトを設定していると思われます。
何か助けていただければ幸いです。
私が間違っているかもしれないが、私はこの記事では、便利な http://www.hanselman.com/blog/SystemThreadingThreadCurrentPrincipalVsSystemWebHttpContextCurrentUserOrWhyFormsAuthenticationCanBeSubtle.aspx またはこの条 http://stackoverflow.com/questions/6810808/threadに来るかもしれないと思います-currentprincipal-identity-vs-httpcontext-user-identity –