title: Federate .NET MVC application with SAML using Sustainsys / Saml2
body: <p>Currently windows authentication is being used by our web app. We need to integrate this to an existing single sign on with SAML. I am looking with <a href="https://github.com/Sustainsys/Saml2" rel="nofollow noreferrer">Sustainsys / Saml2</a> to integrate our web app with SAML. </p>
  
  <p>Our site homepage url is this: 
      <a href="http://siteName/Home/Index" rel="nofollow noreferrer">http://siteName/Home/Index</a></p>
  
  <p>IdP endpoint: 
      <a href="https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite" rel="nofollow noreferrer">https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite</a></p>
  
  <p>When I try to navigate to saml single sign on and enter my credential I am being redirected to our site: <a href="http://siteName/Home/Index" rel="nofollow noreferrer">http://siteName/Home/Index</a> 
  So I supposed that saml environment setup is working correctly</p>
  
  <p>My problem now is, when I navigate to our site homepage, if the user is not yet authenticated, I want it to redirect first to Idp endpoint to authenticate the user: <a href="https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite" rel="nofollow noreferrer">https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite</a></p>
  
  <p>Here's the current web.config I'm trying: </p>
  
  <pre><code>&lt;configSections&gt;
      &lt;section name="system.identityModel" type="System.IdentityModel.Configuration.SystemIdentityModelSection, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
      &lt;section name="system.identityModel.services" type="System.IdentityModel.Services.Configuration.SystemIdentityModelServicesSection, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" /&gt;
      &lt;section name="sustainsys.saml2" type="Sustainsys.Saml2.Configuration.SustainsysSaml2Section, Sustainsys.Saml2" /&gt;
    &lt;/configSections&gt;
    &lt;appSettings&gt;
      &lt;add key="webpages:Version" value="3.0.0.0" /&gt;
      &lt;add key="webpages:Enabled" value="false" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;compilation targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2" /&gt;
      &lt;authentication mode="Windows" /&gt;
      &lt;authorization&gt;
        &lt;deny users="?" /&gt;
      &lt;/authorization&gt;
      &lt;customErrors mode="Off" /&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;modules&gt;
          &lt;add name="SessionAuthenticationModule" type="System.IdentityModel.Services.SessionAuthenticationModule, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /&gt;
          &lt;add name="Saml2AuthenticationModule" type="Sustainsys.Saml2.HttpModule.Saml2AuthenticationModule, Sustainsys.Saml2.HttpModule" /&gt;
      &lt;/modules&gt;
      &lt;security&gt;
          &lt;authentication&gt;
              &lt;windowsAuthentication enabled="true" /&gt;
          &lt;/authentication&gt;
      &lt;/security&gt;
    &lt;/system.webServer&gt;
    &lt;sustainsys.saml2 entityId="https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite" returnUrl="https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite"&gt;
      &lt;identityProviders&gt;
        &lt;add entityId="https://providerName.com:8080/pf/federation_metadata.ping?PartnerSpId=mySite" signOnUrl="https://providerName.com:8080/idp/start/sso.ping?PartnerSpid=mySite" allowUnsolicitedAuthnResponse="true" binding="HttpRedirect"&gt;
          &lt;signingCertificate fileName="~/App_Data/Saml2.cer" /&gt;
        &lt;/add&gt;
      &lt;/identityProviders&gt;
    &lt;/sustainsys.saml2&gt;
    &lt;system.identityModel.services&gt;
      &lt;federationConfiguration&gt;
        &lt;cookieHandler requireSsl="false" name="SampleMvcApplicationAuth" /&gt;
      &lt;/federationConfiguration&gt;
    &lt;/system.identityModel.services&gt;
  </code></pre>