我试图建立滑动WIF会议和需要处理SessionSecurityTokenReceived。如何在Global.asax中处理事件SessionSecurityTokenReceived?
我敢肯定,我做了愚蠢的事情在这里......但VS2010不断告诉我,There is no applicable variable or member
现货如下图所示。任何人都可以将我指向正确的方向吗?我已经搜索了如何定义这个事件处理的实际样本的高低,但我找不到一个。
的Global.asax
protected void Application_Start()
{
FederatedAuthentication.WSFederationAuthenticationModule.SecurityTokenReceived
+= SessionAuthenticationModule_SessionSecurityTokenReceived;
// ^^^ There is no applicable variable or member
}
void SessionAuthenticationModule_SessionSecurityTokenReceived(object sender, SessionSecurityTokenReceivedEventArgs e)
{
DateTime now = DateTime.UtcNow;
DateTime validFrom = e.SessionToken.ValidFrom;
DateTime validTo = e.SessionToken.ValidTo;
if ((now < validTo) &&
(now > validFrom.AddMinutes((validTo.Minute - validFrom.Minute)/2))
)
{
SessionAuthenticationModule sam = sender as SessionAuthenticationModule;
e.SessionToken = sam.CreateSessionSecurityToken(
e.SessionToken.ClaimsPrincipal,
e.SessionToken.Context,
now,
now.AddMinutes(2),
e.SessionToken.IsPersistent);
e.ReissueCookie = true;
}
else
{
//todo: WSFederationHelper.Instance.PassiveSignOutWhenExpired(e.SessionToken, this.Request.Url);
// this code from: http://stackoverflow.com/questions/5821351/how-to-set-sliding-expiration-in-my-mvc-app-that-uses-sts-wif-for-authenticati
var sessionAuthenticationModule = (SessionAuthenticationModule)sender;
sessionAuthenticationModule.DeleteSessionTokenCookie();
e.Cancel = true;
}
}
简单和像魅力一样工作!我怎么可以告诉大家,需要接线了事件和那些不之间的差异 – LamonteCristo