C# using HttpWebRequest Post method doesn't work -


hey i'm trying figure out using httpwebrequest post request login page, yahoo mail, , examine returned page source.

but using post method still got login page.

here method:

public static string getresponse(string surl, ref cookiecontainer cookies, string sparameters)     {         httpwebrequest httprequest = (httpwebrequest)webrequest.create(surl);         httprequest.useragent = "mozilla/5.0 (windows nt 6.1; wow64) applewebkit/537.36 (khtml, gecko) chrome/29.0.1547.66 safari/537.36";         httprequest.cookiecontainer = cookies;         httprequest.method = "post";         httprequest.contenttype = "application/x-www-form-urlencoded";         httprequest.contentlength = sparameters.length;         httprequest.allowautoredirect = true;                      using (stream stream = httprequest.getrequeststream())         {             stream.write(encoding.utf8.getbytes(sparameters), 0, sparameters.length);         }          httpwebresponse httpwebresponse = (httpwebresponse)httprequest.getresponse();          string sresponse;         using (stream stream = httpwebresponse.getresponsestream())         {             streamreader reader = new streamreader(stream, system.text.encoding.getencoding(936));             sresponse = reader.readtoend();         }          return sresponse;     } 

the code call method is:

        string sparameter = ".tries=1&.src=ym&.md5=&.hash=&.js=&.last=&promo=&.intl=us&.lang=en-us&.bypass=&.partner=&.u=eip09319532h1&.v=0&.challenge=3qjvx9eeftjrrabhzp9kgs9it.vo&.yplus=&.emailcode=&pkg=&stepid=&.ev=&hasmsgr=0&.chkp=y&.done=http%3a%2f%2fmail.yahoo.com&.pd=ym_ver%3d0%26c%3d%26ivt%3d%26sg%3d&.ws=1&.cp=0&nr=0&pad=3&aad=3&login=username%40yahoo.com&passwd=xxxxx&.persistent=&.save=&passwd_raw=";         system.net.cookiecontainer coookies = null ;         string sresponse;          sresponse = getresponse(surl, ref coookies, sparameter); 

the string sparameter obtained examining data posted server in firefox's firebug plugin. in parameters posted above, masked user id , password.

i wanted re-use session passed cookiecontainer object reference method.

it compiles , runs, page returned me not logged-in status.

i have read several similar questions on stackoverflow, still can't make method work. appreciated.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -