Tôi đang cố thiết lập các phiên trượt trong WIF và cần xử lý SessionSecurityTokenReceived.Làm cách nào để xử lý sự kiện SessionSecurityTokenReceived trong Global.asax?
Tôi chắc chắn rằng tôi đang làm điều gì đó ngu ngốc ở đây ... nhưng VS2010 tiếp tục nói với tôi rằng There is no applicable variable or member
tại chỗ được minh họa bên dưới. ai đó có thể chỉ cho tôi phương hướng đúng không? Tôi đã tìm kiếm cao và thấp cho các mẫu thực tế làm thế nào để xác định việc xử lý sự kiện này, nhưng tôi không thể tìm thấy một duy nhất.
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;
}
}
Dễ dàng và hoạt động như một sự quyến rũ! Làm thế nào tôi có thể cho biết sự khác biệt giữa các sự kiện cần nối dây và những sự kiện không cần thiết – LamonteCristo