0

I am trying to login to Gmail by posting data.

Here is my code:

     HttpWebRequest hi = (HttpWebRequest)HttpWebRequest.Create("https://www.google.com/accounts/ServiceLoginAuth?service=mail");
     hi.Method = "POST";
     //string PostData = "continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Ftab%3Dwm&service=mail&rm=false&dsh=-28214021908461826&ltmpl=default&scc=1&GALX=6-CDla8snug&pstMsg=1&dnConn=&checkConnection=youtube%3A1271%3A1&checkedDomains=youtube&timeStmp=&secTok=&Email=EMAILADDRESS4u&Passwd=PASSWORD&signIn=Sign+in&rmShown=1";
     hi.ContentType = "application/x-www-form-urlencoded";
     byte[] post = UnicodeEncoding.UTF8.GetBytes(PostData);
     Stream stream = await hi.GetRequestStreamAsync();
     stream.Write(post, 0, PostData.Length);
     WebResponse response = await hi.GetResponseAsync();
     string pageSource;   
     using (StreamReader sr = new StreamReader(response.GetResponseStream()))
     {
         pageSource = sr.ReadToEnd();
     }
     mywebview1.NavigateToString(pageSource);

But when I try to run this, I get an error. How can I resolve this issue?

Your browser's cookie functionality is turned off. Please turn it on.
Scott
  • 21,211
  • 8
  • 65
  • 72
  • 4
    And now we just need a little social engineering/research to get your phone number and we all have access to your google account?! – I'm with Monica Sep 19 '12 at 06:15

1 Answers1

0

We have already one question related to this...

Have a look..

Using WebRequest cookie in WebBrowser

Use cookies from CookieContainer in WebBrowser

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/00a29544-8cf4-4de2-8e7c-e7931b0e2221

Community
  • 1
  • 1
Pushpendra
  • 814
  • 1
  • 6
  • 17