Dlaczego FederatedAuthentication.WSFederationAuthenticationModule miałoby być puste w uwierzytelnianiu federacyjnym MVC Azure ACS?

Usiłuję połączyć uwierzytelnianie federacyjne z .NET 4.5, MVC 4 i aktywne przekierowanie przy użyciu niestandardowej strony logowania po stronie serwera, używając kodu zto samouczek i odto próbka kodu.

Przekierowanie do metody LogOn mojego AccountController działa dobrze, a metoda wygląda tak:

public ActionResult LogOn()
{
    HrdClient hrdClient = new HrdClient();
    WSFederationAuthenticationModule fam = FederatedAuthentication.WSFederationAuthenticationModule; /*** Fails here because this is null **/
    HrdRequest request = new HrdRequest(fam.Issuer, fam.Realm, context: Request.QueryString["ReturnUrl"]);
    IEnumerable<HrdIdentityProvider> hrdIdentityProviders = hrdClient.GetHrdResponse(request);
    ViewData["Providers"] = hrdIdentityProviders;
    return View();
}

To się nie powiedzie, ponieważFederatedAuthentication.WSFederationAuthenticationModule ma wartość null.

Korzystając z VS 2012, uruchomiłem nowego kreatora tożsamości i dostępu (który wydaje się zastępować stare okno dialogowe STS). To dało mi folder FederationMetadata, który wydaje się poprawny i kilka modyfikacji w moim Web.Config. W szczególności sekcja modułów wygląda następująco:

<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">
  <add name="WSFederationAuthenticationModule" type="System.IdentityModel.Services.WSFederationAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
  <add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
</modules>

I widząc odpowiedzi SO8937123 i8926099Dodałem również następujące:

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

I wreszcie moja konfiguracja pakietów nuget pokazuje Microsoft.IdentityModel, do którego poprawnie odwołuje się aplikacja MVC:

<packages>
  <package id="Microsoft.IdentityModel" version="6.1.7600.16394" targetFramework="net45" />
</packages>

Widziałem teżto pytanie na social.msdn, co wydaje się sugerować, że okno STS musi zostać uruchomione.

Czy ktoś może wyjaśnić dlaczegoFederatedAuthentication.WSFederationAuthenticationModule byłoby nieważne i co mogę zrobić, aby temu zapobiec?

questionAnswers(1)

yourAnswerToTheQuestion