Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are encoding the form incorrectly. You should only encode the values:</p> <pre><code>StringBuilder postData = new StringBuilder(); postData.Append("username=" + HttpUtility.UrlEncode(uname) + "&amp;"); postData.Append("password=" + HttpUtility.UrlEncode(pword) + "&amp;"); postData.Append("url_success=" + HttpUtility.UrlEncode(urlSuccess) + "&amp;"); postData.Append("url_failed=" + HttpUtility.UrlEncode(urlFailed)); </code></pre> <p><strong>edit</strong> </p> <p>I was incorrect. According to <a href="https://tools.ietf.org/html/rfc1866#section-8.2" rel="noreferrer">RFC1866 section 8.2.1</a> both names and values should be encoded.</p> <p>But for the given example, the names do not have any characters that needs to be encoded, so in this case my code example is correct ;)</p> <p>The code in the question is still incorrect as it would encode the equal sign which is the reason to why the web server cannot decode it.</p> <p>A more proper way would have been:</p> <pre><code>StringBuilder postData = new StringBuilder(); postData.AppendUrlEncoded("username", uname); postData.AppendUrlEncoded("password", pword); postData.AppendUrlEncoded("url_success", urlSuccess); postData.AppendUrlEncoded("url_failed", urlFailed); //in an extension class public static void AppendUrlEncoded(this StringBuilder sb, string name, string value) { if (sb.Length != 0) sb.Append("&amp;"); sb.Append(HttpUtility.UrlEncode(name)); sb.Append("="); sb.Append(HttpUtility.UrlEncode(value)); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload