orourkedd
orourkedd

Reputation: 6421

WIF: SessionAuthenticationModule Always Null

I'm trying to get WIF set up on an MVC project I'm working on but to no avail. The issue I'm having is that FederatedAuthentication.SessionAuthenticationModule is always null. I have added the following lines to web.config under 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" />

I also attempted to init the module:

<modules>
  <add name="SessionAuthenticationModule"
       type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
       preCondition="managedHandler" />
</modules>

Still nothing. I installed WIF through nuget. I noticed that the namespace for WIF for most of the docs online (like what I posted above) is System.IdentityModel whereas the namespace for the what I have through nuget is Microsoft.IdentityModel. Could this be causing the trouble?

A few specs:

Standard MVC 4 Project

Using Microsoft.IdentityModel.dll v3.5.0.0

Upvotes: 0

Views: 617

Answers (2)

Ruhollah Delpak
Ruhollah Delpak

Reputation: 147

You don't need to install WIF 4 with nuget. .Net framework 4.5 has built-in support for this library. your web.config must be like this:

    <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>

and:

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

Upvotes: 1

Mike Goodwin
Mike Goodwin

Reputation: 8880

System.identitymodel.xxx is the .Net 4.5 version if WIF where everything is merged into the core framework.

Microsoft.identitymodel.xxx is the .net 4 version that is installed separately.

Upvotes: 0

Related Questions