Click here to Skip to main content
15,923,273 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to get result page source in post method , give inputs in first page and get result page source. Actually it have referral url.

i am trying below code but i am getting first page source code
i can not getting second page source code.


please solve this issue

Thank you.

What I have tried:

string strURL = "";
           string strPostData = "";
           string strResult = "";
           HttpWebRequest wbrq = default(HttpWebRequest);
           HttpWebResponse wbrs = default(HttpWebResponse);
           StreamWriter sw = default(StreamWriter);
           StreamReader sr = default(StreamReader);
           strURL = "http://cbseresults.nic.in/aieee/cbseaieee.asp";
           strPostData = string.Format("regno", "20616948");
           wbrq = WebRequest.Create(strURL);
           wbrq.Method = "POST";
           wbrq.Referer = "http://cbseresults.nic.in/aieee/cbseaieee.asp";
           wbrq.ContentLength = strPostData.Length;
           wbrq.ContentType = "application/x-www-form-urlencoded";
           StreamWriter sw= new StreamWriter(wbrq.GetRequestStream);
            sw.Write(strPostData);
            sw.Close();
            wbrs = wbrq.GetResponse();
            StreamReader sr = new StreamReader(wbrs.GetResponseStream);
            strResult = sr.ReadToEnd().Trim();
            sr.Close();
            richTextBox1.Text = strResult;
Posted
Updated 30-Apr-18 4:14am

1 solution

Quote:
strPostData = string.Format("regno", "20616948");

If you debug your code, you'll see that the result of that string.Format call is the literal string "regno".

That is not a valid application/x-www-form-urlencoded body.

I assume you meant:
strPostData = "regno=20616948"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900