InitializePropertiesFromConfiguration(String serviceName)NullReferenceException

时间:2016-04-18 18:06:31

标签: c# .net authentication adfs asp.net-authentication

我已根据http://www.wiktorzychla.com/2014/11/forms-authentication-revisited-for-net.html的说明配置了“SessionAuthenticationModule”。我的应用程序在.Net 3.5中,因此我根据“WIF 3.5和WIF 4.5之间的命名空间映射”更改了库映射。当我运行它时,它会抛出下面显示的异常。 “

Object reference not set to an instance of an object. 
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error: 


 An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
   Microsoft.IdentityModel.Web.SessionAuthenticationModule.InitializePropertiesFromConfiguration(String serviceName) +16
   Microsoft.IdentityModel.Web.SessionAuthenticationModule.InitializeModule(HttpApplication context) +124
   Microsoft.IdentityModel.Web.HttpModuleBase.Init(HttpApplication context) +30

” 主要配置设置如下所示。

<section name="Microsoft.IdentityModel" type="Microsoft.IdentityModel.Configuration.SystemIdentityModelSection, Microsoft.IdentityModel"/>
    <section name="Microsoft.IdentityModel.Protocols" type="Microsoft.IdentityModel.Web.Configuration.SystemIdentityModelServicesSection, Microsoft.IdentityModel.Protocols.WSFederation"/>
  </configSections>




<Microsoft.IdentityModel></Microsoft.IdentityModel>

<Microsoft.IdentityModel.Protocols>    
    <federationConfiguration>
      <cookieHandler requireSsl="false"/>
    </federationConfiguration>
  </Microsoft.IdentityModel.Protocols>

我的配置有什么问题?请帮帮我。

1 个答案:

答案 0 :(得分:0)

您似乎缺少web.config中的SAM。

  <httpModules>
         <add name="SessionAuthenticationModule" 
              type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
  </httpModules>

看一下针对.NET 3.5的旧教程

http://www.wiktorzychla.com/2011/08/quest-for-customizing-adfs-sign-ing-web.html