title: How to single logout from Azure AD B2C with ITFoxTech SAML 2 library?
body: <p>I've implemented a Web Application (Angular frontend and .NET backend) with Azure B2C as identity provider with custom policies via SAML.</p>
  <p>On the side of login everything is working fine. But now I'm struggeling with the single logout. What I want to achive is, that the user is logged out from Azure B2C and all web applications, when the user clicks on the logout button in the web app.</p>
  <p>Therefore the Angular app calls the &quot;singlelogout&quot; endpoint of the backend, when clicking &quot;Logout&quot;.</p>
  <p>I'm using the ITFoxTech SAML2 library and the logout method is implemented as described in the documentation: <a href="https://www.itfoxtec.com/identitysaml2" rel="nofollow noreferrer">https://www.itfoxtec.com/identitysaml2</a></p>
  <pre><code>[Route(&quot;SingleLogout&quot;)]
  public async Task&lt;IActionResult&gt; SingleLogout()
  {
      Saml2StatusCodes status;
  var requestBinding = new Saml2PostBinding();
  var logoutRequest = new Saml2LogoutRequest(config, User);
  try
      {
          requestBinding.Unbind(Request.ToGenericHttpRequest(), logoutRequest);
          status = Saml2StatusCodes.Success;
          await logoutRequest.DeleteSession(HttpContext);
      }
  catch (Exception exc)
      {
  // log exception
          Debug.WriteLine(&quot;SingleLogout error: &quot; + exc.ToString());
          status = Saml2StatusCodes.RequestDenied;
      }
  
  var responsebinding = new Saml2PostBinding();
      responsebinding.RelayState = requestBinding.RelayState;
  var saml2LogoutResponse = new Saml2LogoutResponse(config)
      {
          InResponseToAsString = logoutRequest.IdAsString,
          Status = status,
      };
  return responsebinding.Bind(saml2LogoutResponse).ToActionResult();
  }
  </code></pre>
  <p>When the method is called the logoutRequest seems to be build correctly:</p>
  <p><a href="https://i.stack.imgur.com/5iyhl.png" rel="nofollow noreferrer">LogoutRequest</a></p>
  <p>But then I get the following exception:</p>
  <pre><code>SingleLogout error: ITfoxtec.Identity.Saml2.Saml2BindingException: HTTP Form does not contain SAMLRequest
     at ITfoxtec.Identity.Saml2.Saml2PostBinding.Read(HttpRequest request, Saml2Request saml2RequestResponse, String messageName, Boolean validateXmlSignature, Boolean detectReplayedTokens)
     at ITfoxtec.Identity.Saml2.Saml2PostBinding.UnbindInternal(HttpRequest request, Saml2Request saml2RequestResponse, String messageName)
     at ITfoxtec.Identity.Saml2.Saml2Binding`1.Unbind(HttpRequest request, Saml2Request saml2Request)
     at durstgroup.myportal.webapp.Controllers.AuthController.SingleLogout() in /Users/xxxxx/dev/xxxx/xxxxxxxx/xxxxxx.myportal.webapp/Controllers/AuthController.cs:line 190
  </code></pre>
  <p>Has somebody an idea what I'm doing wrong?</p>
  <p>Thanks for your help und kind regards
  Alex</p>