最近我开始在现有的Web应用程序上使用基于声明的身份验证。一切运作良好,但为了更好地处理SessionSecurity令牌的到期,我想要使用滑动到期。注册SecurityTokenReceived事件处理程序
但是,我很难注册SecurityTokenReceived事件的事件处理程序。
我的处理方法是指像这样在Global.asax.cs中:
protected void SessionAuthenticationModule_SessionSecurityTokenReceived(object sender, SessionSecurityTokenReceivedEventArgs e) { ... }
但在Application_Start像这样注册此处理方法将同一文件的:
FederatedAuthentication.WSFederationAuthenticationModule.SecurityTokenReceived += SessionAuthenticationModule_SessionSecurityTokenReceived;
视觉Studio响应SessionAuthenticationModule_SessionSecurityTokenReceived没有与委托System.EventHandler匹配的重载。
我在web.config中的部分如下设置:
<securityTokenHandlers>
<add type="Microsoft.IdentityModel.Tokens.SessionSecurityTokenHandler, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sessionTokenRequirement lifetime="0:02" />
</add>
</securityTokenHandlers>
我看了一些MSDN上的可用文档,但我不明白为什么事件处理程序是不能接受的。任何人都可以协助吗?
非常感谢Danila,您指出了我犯的错误。我已经回答了我自己的问题,但投了你的答案,因为它也帮助我 – Raybiez 2013-04-08 12:08:14