title: How to send POST request to JSF with help HttpWebRequest
body: <p>I send post request with body <code>login=login&amp;login:loginName={0}&amp;login:password={1}&amp;login:clientCode=&amp;login:j_idt171=&amp;javax.faces.ViewState=stateless</code>
  with help <code>HttpWebRequest</code>. Before that I was doing <code>GET</code> request, for getting <code>JSESSIONID</code>.
  Web form looks like that:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form id="login" name="login" method="post" action="/csologin/login.jsf"&gt;
  &lt;input type="hidden" name="login" value="login"&gt;
  &lt;div id="login:j_idt122" class="ui-messages ui-widget" aria-live="polite"&gt;&lt;/div&gt;&lt;table border="0" cellpadding="2" cellspacing="0" width="580px"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class="ecol1"&gt;&lt;label id="login:j_idt125" class="ui-outputlabel ui-widget fbold" for="login:loginName"&gt;Username&lt;span class="ui-outputlabel-rfi"&gt;*&lt;/span&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td class="ecol2"&gt;&lt;input id="login:loginName" name="login:loginName" type="text" autocomplete="off" size="40" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"&gt;&lt;/td&gt;
              &lt;td class="ecol3"&gt;&lt;div id="login:j_idt126" aria-live="polite" class="ui-message"&gt;&lt;/div&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;table border="0" cellpadding="2" cellspacing="0" width="580px"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class="ecol1"&gt;&lt;label id="login:j_idt132" class="ui-outputlabel ui-widget fbold" for="login:password"&gt;Password&lt;span class="ui-outputlabel-rfi"&gt;*&lt;/span&gt;&lt;/label&gt;&lt;/td&gt;
              &lt;td class="ecol2"&gt;&lt;input id="login:password" name="login:password" type="password" class="ui-inputfield ui-password ui-widget ui-state-default ui-corner-all ui-state-hover" autocomplete="off" size="40" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"&gt;&lt;/td&gt;
              &lt;td class="ecol3"&gt;&lt;div id="login:j_idt133" aria-live="polite" class="ui-message"&gt;&lt;/div&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;table border="0" cellpadding="2" cellspacing="0" width="580px"&gt;
      &lt;tbody&gt;
          &lt;tr&gt;
              &lt;td class="ecol1"&gt;&lt;label id="login:j_idt135" class="ui-outputlabel ui-widget fbold" for="login:clientCode"&gt;Client Code&lt;/label&gt;&lt;/td&gt;
              &lt;td class="ecol2"&gt;&lt;input id="login:clientCode" name="login:clientCode" type="text" maxlength="32" size="40" class="ui-inputfield ui-inputtext ui-widget ui-state-default ui-corner-all" role="textbox" aria-disabled="false" aria-readonly="false" aria-multiline="false"&gt;&lt;/td&gt;
              &lt;td class="ecol3"&gt;&lt;div id="login:j_idt136" aria-live="polite" class="ui-message"&gt;&lt;/div&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;br&gt;&lt;div class="text-center"&gt;
      &lt;button id="login:j_idt139" name="login:j_idt139" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="barWaitDialog.show();" type="submit" role="button" aria-disabled="false"&gt;&lt;span class="ui-button-text ui-c"&gt;Login&lt;/span&gt;&lt;/button&gt;
      &lt;!-- &amp;lt;p:commandButton value="Clear" onclick="clearVisibleTextFields();" /&amp;gt;  --&gt;&lt;button id="login:j_idt141" name="login:j_idt141" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" onclick="PrimeFaces.ab({source:'login:j_idt141',oncomplete:function(xhr,status,args){clearVisibleTextFields();;}});return false;" type="submit" role="button" aria-disabled="false"&gt;&lt;span class="ui-button-text ui-c"&gt;Clear&lt;/span&gt;&lt;/button&gt;&lt;button id="login:j_idt142" name="login:j_idt142" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" type="submit" role="button" aria-disabled="false"&gt;&lt;span class="ui-button-text ui-c"&gt;Cancel&lt;/span&gt;&lt;/button&gt;
  &lt;/div&gt;&lt;input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="stateless" autocomplete="off"&gt;
  </code></pre>
  
  <p>
  Not authenticated, it returns a redirect to login page. What am I doing wrong?</p>