A
Al Cadalzo
I'm trying to simulate a form post (i.e. Method="POST").
The FORM POST I'm trying to simulate is similar to this:
<FORM NAME=SearchForm METHOD=POST ACTION=Search>
<SELECT name="criteriaA" >
<OPTION VALUE=1>AAAAAAAAAAA</OPTION>
<OPTION VALUE=2>BBBBBBBBBBBB</OPTION>
</SELECT>
....
</FORM>
Here is my code:Uri httpSite = new Uri(url);
WebRequest wreq = WebRequest.Create(httpSite);
wreq.ContentType = "application/x-www-form-urlencoded";
wreq.Method = "POST";
string formvars = string.Empty;
formvars = "criteriaA=1&criteriaB=2";
Byte[] byteArray = Encoding.UTF8.GetBytes(formvars);
wreq.ContentLength = byteArray.Length;
Stream reqStream = wreq.GetRequestStream();
reqStream.Write(byteArray, 0, byteArray.Length);
reqStream.Close();
<<
Am I specifying the form variables correctly?
The FORM also has an ACTION=Search
How do I pass the ACTION=Search in my WebRequest?
I'm getting a response back with html of the page I'm requesting but it does
not have any search results.
The area of the page where the search results would appear is blank.
Any help or hints anyone can provide are appreciated.
Thanks,
Al
The FORM POST I'm trying to simulate is similar to this:
<FORM NAME=SearchForm METHOD=POST ACTION=Search>
<SELECT name="criteriaA" >
<OPTION VALUE=1>AAAAAAAAAAA</OPTION>
<OPTION VALUE=2>BBBBBBBBBBBB</OPTION>
</SELECT>
....
</FORM>
Here is my code:Uri httpSite = new Uri(url);
WebRequest wreq = WebRequest.Create(httpSite);
wreq.ContentType = "application/x-www-form-urlencoded";
wreq.Method = "POST";
string formvars = string.Empty;
formvars = "criteriaA=1&criteriaB=2";
Byte[] byteArray = Encoding.UTF8.GetBytes(formvars);
wreq.ContentLength = byteArray.Length;
Stream reqStream = wreq.GetRequestStream();
reqStream.Write(byteArray, 0, byteArray.Length);
reqStream.Close();
<<
Am I specifying the form variables correctly?
The FORM also has an ACTION=Search
How do I pass the ACTION=Search in my WebRequest?
I'm getting a response back with html of the page I'm requesting but it does
not have any search results.
The area of the page where the search results would appear is blank.
Any help or hints anyone can provide are appreciated.
Thanks,
Al