title: How to extract state parameter from OpenIdConnect Token response in .Net Core MVC
body: <p>We are using Azure b2c to handle our logins on our .net core MVC site.
  We would like to use the optional <code>state</code> parameter to hold onto some data/a value between the initial request to the site (this value would likely be in a querystring param) which is then sent off to b2c to login, and the successfully logged in return back to the site.
  OpenIDConnect allow the setting of this state value in the request, and will pass it back with the token response.</p>
  
  <p>It appears that setting the value is relatively simple; in the <code>OnRedirectToIdentityProvider</code> event in the <code>OpenIdConnectOptions</code> like so:</p>
  
  <pre><code>public Task OnRedirectToIdentityProvider(RedirectContext context){
     ...   
     context.ProtocolMessage.SetParameter("state", "mystatevalue");
     ...
  }
  </code></pre>
  
  <p>however, I cannot see how to get this value back again when the user is returned.</p>
  
  <p>I can see that the <code>OnTicketReceived</code> event is hit, and this has a <code>TicketReceivedContext</code> which has a <code>Form</code> property with a <code>state</code> value in it, however this is still encrypted.</p>
  
  <p>Where would i be able to get the un-encrypted value back from?</p>
  
  <p>I have had a look at the Azure docs for b2c but I cannot find an example on this.</p>
  
  <p>thanks</p>