title: Get Authenication cookie from WebClient
body: <p>I'm trying to get an authenication cookie from an website. I have managed to get this working with an tcl-script. The script looks like this:</p>
  
  <pre><code>proc get_cookie { connector_id } {
      global USER PASSWORD URL
  
      set post_url "[get_proxy_url $connector_id]/httpaccess.net/login"
  
      set post_data "user=[urlencode ${USER}]&amp;password=[urlencode ${PASSWORD}]&amp;url=[urlencode $URL]&amp;serviceId=${connector_id}&amp;token=12345"
  
      catch { 
          exec wget --post-data $post_data --no-check-certificate $post_url --max-redirect=0 -q -S -O - 2&gt;@1
      } stderr
  
      if [string match "*HTTP/1.1 302 Found*" $stderr] {
          if [regexp {Location: *https://[0-9a-z\-.]+/httpaccess.net/([^/]+)/} $stderr dummy cookie] {
              return $cookie
          }
      }
  
      error "Error getting login cookie for $connector_id: $stderr"
  }
  </code></pre>
  
  <p>Now I'm trying to get this to work in an c# application. But it is not working I'm only getting the html code of the homepage. My code looks like that now. What is the problem?</p>
  
  <pre><code>public MainWindow()
  {
    InitializeComponent();
  
    string user = "man@gmail.de";
    string password = "xxxxxx";
    string url = "http://dev.net/testfiles/test_5kB.htm";
    string connectorId = "SDYYYYYYYHDMN354KS59";
    string post_data = string.Format("user={0}&amp;password={1}&amp;url={2}&amp;serviceId={3}&amp;token={4}", user, password, url, connectorId, "12345");
  
    var cli = new WebClient();
    var data = cli.UploadString("https://http.aa.net/xxx/httpaccess.net/login", post_data);
  }
  </code></pre>