title: how to Login to website programatically using using C#
body: <p>I want to login to this website using C#: 
  Here is my attempt but its sending me to first page. Not returning me the next page, that should be visible after login, please help me to resolve this:</p>
  
  <pre><code>string formParams = 
  string.Format("mail={0}&amp;password={1}", store@admin.com", "admin");
        string cookieHeader;
        WebRequest req = WebRequest.Create("http://muslimgowns.com/dashboard/login/public_login");
              req.ContentType = "application/x-www-form-urlencoded";
              req.Method = "POST";
              byte[] bytes = Encoding.ASCII.GetBytes(formParams);
              req.ContentLength = bytes.Length;
              using (Stream os = req.GetRequestStream())
              {
                  os.Write(bytes, 0, bytes.Length);
              }
              WebResponse resp = req.GetResponse();
              cookieHeader = resp.Headers["Set-cookie"];
              using (StreamReader sr = new  StreamReader(resp.GetResponseStream()))
              {
                  string pageSource = sr.ReadToEnd();
                  File.AppendAllText("first.txt", pageSource);
              }
  
              string pageSource1;
              string getUrl = "http://muslimgowns.com/dashboard/home";
              WebRequest getRequest = WebRequest.Create(getUrl);
              getRequest.Headers.Add("Cookie", cookieHeader);
              WebResponse getResponse = getRequest.GetResponse();
              using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
              {
                  pageSource1 = sr.ReadToEnd();
                  File.AppendAllText("second.txt", pageSource1);
              }
          }
  </code></pre>