是什么让FederatedAuthentication.SessionAuthenticationModule返回NULL? [英] What makes the FederatedAuthentication.SessionAuthenticationModule return NULL?

查看:363
本文介绍了是什么让FederatedAuthentication.SessionAuthenticationModule返回NULL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道为什么,但我FederatedAuthentication.SessionAuthenticationModule被解析为NULL,并撞毁我的应用程序,当我尝试运行我的ClaimsTransformer()模块:

I'm not sure why but my FederatedAuthentication.SessionAuthenticationModule is resolving as NULL and crashing my app when I try to run my ClaimsTransformer() module:

    public void EstablishSession(ClaimsPrincipal principal)
    {
        var sessionToken = new SessionSecurityToken(principal, TimeSpan.FromHours(8))
        {
            IsPersistent = false, // make persistent
            IsReferenceMode = true // cache on server
        };


        FederatedAuthentication.SessionAuthenticationModule.WriteSessionTokenToCookie(sessionToken);
       // FederatedAuthentication.SessionAuthenticationModule == null and I throw an error :(
    }

下面是什么在我的web.config:

Here's what's in my web.config:

<configSections>
  <section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
  <section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
</configSections>
<system.web>
  <authentication mode="None" />
</system.web>
<system.webServer>
  <modules runAllManagedModulesForAllRequests="true">
    <remove name="RoleManager" />
    <remove name="FormsAuthentication" />
    <remove name="SessionAuthenticationModule" />
    <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </modules>
</system.webServer>
<system.identityModel>
  <identityConfiguration>
    <claimsAuthenticationManager type="Web.Infrastructure.Authentication.ClaimsTransformer, Web" />
  </identityConfiguration>
</system.identityModel>
<system.identityModel.services>
  <federationConfiguration>
    <cookieHandler requireSsl="false" />
  </federationConfiguration>
</system.identityModel.services>

这是推动我疯了,因为我有一个(概念验证)运行的代码项目没有任何问题,并出现是我需要得到这个功能的工作,但对于一些奇怪的原因,当我尝试在我们实际的项目实施,我FederatedAuthentication.SessionAuthenticationModule始终是NULL。

This is driving me crazy as I have the code running in a (proof of concept) project without any problems, and appears is all I need to get this functionality working, but for some strange reason, when I try to implement in our real project, my FederatedAuthentication.SessionAuthenticationModule is always NULL.

我缺少的是在这里吗?有任何想法吗?为什么不SessionAuthenticationModule正确初始化?

What am I missing here? Any Ideas? Why is the SessionAuthenticationModule not initializing correctly?

推荐答案

我在与已经工作的项目,几乎FederatedAuthentication.WSFederationAuthenticationModule相同的行为。

I'm having almost same behavior with already-working project and FederatedAuthentication.WSFederationAuthenticationModule.

问题解决了从IIS Express设为我切换到完整的IIS(对项目文件不良合并)。

Problem solved my switching from IIS Express to full IIS (bad merge of for project file).

你也可以尝试这个模块添加不仅一节,但是:

Also you can try to add this module not only to a section, but :

<system.web>
<httpModules>
<add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

您可以参考这个的为样本MSDN文章

这篇关于是什么让FederatedAuthentication.SessionAuthenticationModule返回NULL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆