title: Decode Form Urlencoded UTF8 in C#
body: <p><strong>Edit</strong> I'd misunderstood what was happening here.. there is a POST send, then receive back a result, then the URL string which I'm seeing here is part of the the query string... so I can't decode what this really is, as it is encoded by the payment gateway people and not me.</p>
  
  <p>I'd like to decode a URL string</p>
  
  <p>Here is the code:</p>
  
  <pre><code>private string SubmitXml(string InputXml)
      {
          string result = InputXml.ToString();
  
          HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(_WebServiceUrl);
          webReq.Method = "POST";
  
          byte[] reqBytes;
  
          reqBytes = System.Text.Encoding.UTF8.GetBytes(InputXml);
          webReq.ContentType = "application/x-www-form-urlencoded";
          webReq.ContentLength = reqBytes.Length;
          webReq.Timeout = 5000;
          Stream requestStream = webReq.GetRequestStream();
          requestStream.Write(reqBytes, 0, reqBytes.Length);
          requestStream.Close();
  
          HttpWebResponse webResponse = (HttpWebResponse)webReq.GetResponse();
  </code></pre>
  
  <p>Here is the InputXml:   </p>
  
  <pre><code> - &lt;GenerateRequest&gt;
    &lt;PxPayUserId&gt;KoruCareCHCH_Dev&lt;/PxPayUserId&gt; 
    &lt;PxPayKey&gt;47d99ccdcae54816ecd78c9a80f8878c466a7ed829480e59d421cc4c456cbd93&lt;/PxPayKey&gt; 
    &lt;AmountInput&gt;345.00&lt;/AmountInput&gt; 
    &lt;BillingId /&gt; 
    &lt;CurrencyInput&gt;NZD&lt;/CurrencyInput&gt; 
    &lt;DpsBillingId /&gt; 
    &lt;DpsTxnRef /&gt; 
    &lt;EmailAddress /&gt; 
    &lt;EnableAddBillCard /&gt; 
    &lt;MerchantReference&gt;43&lt;/MerchantReference&gt; 
    &lt;TxnData1 /&gt; 
    &lt;TxnData2 /&gt; 
    &lt;TxnData3 /&gt; 
    &lt;TxnType&gt;Purchase&lt;/TxnType&gt; 
    &lt;TxnId&gt;43&lt;/TxnId&gt; 
    &lt;UrlFail&gt;http://localhost:1527/Auction/PurchaseTickets.aspx&lt;/UrlFail&gt; 
    &lt;UrlSuccess&gt;http://localhost:1527/Auction/PurchaseTickets.aspx&lt;/UrlSuccess&gt; 
    &lt;Opt /&gt; 
    &lt;/GenerateRequest&gt;
  </code></pre>
  
  <p>Here is the URL</p>
  
  <p><a href="https://sec2.paymentexpress.com/pxpay/pxpay.aspx?userid=KoruCareCHCH_Dev&amp;request=v5lK0D7j3qnGqQVnj3WThhuS5PoWwKhdLUXfnL1hiSzYzxzkKVtTbLKC49e0qerYoTAofoBXfkWHjJdtOEV1MrnEBZ3p9b-G5fTsS-sLqc76RhHOb8HTxtwe0EQ1kz1iCf2ExIgKRod-FPQTKf6XoTLLlQ4jhcrO7yQczrq1Hft5pB98LMJCdBX0FDnA5NV0ZGApR0NaCMy-xbpsVSsyTbSdmp03aiHpGXI4up2RxrBFhbiEOZKtpKkjUpqJ90UuoXmFwqTC5Pj0g1mx3VRV2ee358Tnu1_kuEID_RaP8sZNTVlAMY5-8qjB-u0dgM4ya8Faxxyw5AhyE=" rel="nofollow">https://sec2.paymentexpress.com/pxpay/pxpay.aspx?userid=KoruCareCHCH_Dev&amp;request=v5lK0D7j3qnGqQVnj3WThhuS5PoWwKhdLUXfnL1hiSzYzxzkKVtTbLKC49e0qerYoTAofoBXfkWHjJdtOEV1MrnEBZ3p9b-G5fTsS-sLqc76RhHOb8HTxtwe0EQ1kz1iCf2ExIgKRod-FPQTKf6XoTLLlQ4jhcrO7yQczrq1Hft5pB98LMJCdBX0FDnA5NV0ZGApR0NaCMy-xbpsVSsyTbSdmp03aiHpGXI4up2RxrBFhbiEOZKtpKkjUpqJ90UuoXmFwqTC5Pj0g1mx3VRV2ee358Tnu1_kuEID_RaP8sZNTVlAMY5-8qjB-u0dgM4ya8Faxxyw5AhyE=</a></p>
  
  <p><strong>Problem:</strong> How do I decode the URL request=blahblah    back into XML</p>
  
  <p>I'm doing this to try and prove what is contained in the URL string (it should be just like the XML above!)</p>