Io non so perché ma il mio FederatedAuthentication.SessionAuthenticationModule sta risolvendo come NULL e schiantarsi mia app quando provo a eseguire il mio ClaimsTransformer) modulo (:Cosa rende FederatedAuthentication.SessionAuthenticationModule restituito NULL?
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 :(
}
Ecco cosa c'è nel mio 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>
questo mi sta facendo impazzire come io ho il codice in esecuzione in un (proof of concept) progetto senza alcun problema, e sembra è tutto quello che ho bisogno di ottenere questa funzionalità di lavoro, ma per qualche strana ragione, quando cerco di implementare nel nostro vero progetto, il mio FederatedAuthentication.SessionAuthenticationModule è sempre NULL.
Cosa mi manca qui? Qualche idea? Perché il SessionAuthenticationModule non si sta inizializzando correttamente?
Perché si aggiungono tre 'rimuovere' nodo prima di aggiungere SessionAuthenticationModule? –
Nel caso in cui l'impostazione sia stata aggiunta da qualche altra parte nella catena .config. Rimuovendo poi aggiunto che ho visto prima, e visto che il mio codice non funzionava, stavo provando tutto ... – user1265146