title: Logging into website via C#
body: <p>I have tried everything I can find on the web on how to implement this to log into this site. Here is the most recent failure.</p>
  
  <pre><code> // I have tried with multiple different URLS this one 
   // and http://www.movable.com/login do not throw errors
   string url = "http://portal.movable.com/";
   string username = "&lt;myusername&gt;";
   string password = "&lt;mypassword&gt;";
   string authTok = @"+HOt3NTkkIAHkMSMvzQisEquhun9xvIG1mHzIEh6CAo=";
   string postData = "utf8=✓" + "&amp;authenticity_token=" + authTok +
        "&amp;user[login]=" + username + 
        "&amp;user[password]=" + password + "&amp;user[offset]=-5";
  
  var container = new CookieContainer();
  var buffer = Encoding.UTF8.GetBytes(postData);
  
  var request = (HttpWebRequest)HttpWebRequest.Create(url);
  request.CookieContainer = container;
  request.UserAgent = "Mozilla/5.0";
  request.Method = "POST";
  request.KeepAlive = true;
  request.AllowAutoRedirect = true;
  request.CookieContainer = container;
  request.ContentLength = buffer.Length;
  request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
  
  using (var requestStream = request.GetRequestStream())
      requestStream.Write(buffer, 0, buffer.Length);
  
  using (var response = request.GetResponse())
  {
  
          using (var reader = new StreamReader(response.GetResponseStream()))
          {
              var result = reader.ReadToEnd();
              //this is to read the page source after the request
              MessageBox.Show(result); 
          }             
  }
  </code></pre>
  
  <p>Also here is the relevant data from the site (I know the tokens are different in the example I have made them the same and it doesnt work)</p>
  
  <pre><code>&lt;form accept-charset="UTF-8" action="/signin" class="new_user" id="new_user" method="post"&gt;&lt;div style="margin:0;padding:0;display:inline"&gt;&lt;input name="utf8" type="hidden" value="&amp;#x2713;" /&gt;&lt;input name="authenticity_token" type="hidden" value="hHfoUnIbi+6RB51x1cqXqAYHkjz9mCi7nc86gMdiMOo=" /&gt;&lt;/div&gt;
  
      &lt;p class="notice"&gt;Signed out successfully.&lt;/p&gt;
  
    &lt;h2&gt;login to your account&lt;/h2&gt;
  
    &lt;label for="user_login"&gt;Login&lt;/label&gt;
    &lt;input id="user_login" name="user[login]" size="30" type="text" /&gt;
    &lt;label for="user_password"&gt;Password&lt;/label&gt;
    &lt;input id="user_password" name="user[password]" size="30" type="password" /&gt;
  
    &lt;input id="user_offset" name="user[offset]" type="hidden" /&gt;
  
  
    &lt;label for="user_remember_me"&gt;
      &lt;input name="user[remember_me]" type="hidden" value="0" /&gt;&lt;input id="user_remember_me" name="user[remember_me]" type="checkbox" value="1" /&gt; 
      Remember me on this computer.
    &lt;/label&gt;
    &lt;button class="login" name="button" type="submit"&gt;Login&lt;/button&gt;
      &lt;a href="/users/password/new" class="forgotPassword"&gt;Forgot password?&lt;/a&gt;
    &lt;/form&gt;  &lt;/div&gt;
  </code></pre>