Why can't I POST to this page with HttpWebRequest?

B

branden.hughes

http://www.dcor.state.ga.us/GDC/OffenderQuery/jsp/OffQryForm.jsp?Institution=vDisclaimer=True

Every time I try it just kicks back the same HTML you'd find from the
link above rather than a page displaying a particular individuals
records. I've tried some generic cookie code to no avail. Any ideas?
I'm working to get a huge process automated for work and this is
literally the only missing piece to the puzzle. Thanks!!

Code below:
string CommandURI =
"http://www.dcor.state.ga.us/GDC/OffenderQuery/jsp/OffQryForm.jsp?Institution=vDisclaimer=True";

HttpWebRequest myWebRequest = (HttpWebRequest)
WebRequest.Create(CommandURI);

myWebRequest.CookieContainer = new CookieContainer();
if (this.Cookies != null && this.Cookies.Count > 0)
myWebRequest.CookieContainer.Add(this.Cookies);

myWebRequest.ContentType = "application/x-www-form-urlencoded";
myWebRequest.Method = "POST";
byte [] bytes =
System.Text.Encoding.ASCII.GetBytes("vUnoCaseNoRadioButton=UNO_NO&vOffenderId=365172");

myWebRequest.ContentLength = bytes.Length;
Stream OutputStream = myWebRequest.GetRequestStream ();
OutputStream.Write (bytes, 0, bytes.Length);
OutputStream.Close ();
HttpWebResponse MyWebResponse = (HttpWebResponse)
myWebRequest.GetResponse();
Stream MyStream = MyWebResponse.GetResponseStream();

// *** Save the cookies on the persistent object
if (MyWebResponse.Cookies.Count > 0)
this.Cookies = MyWebResponse.Cookies;

StreamReader MyStreamReader = new StreamReader(MyStream);
string tryThis = MyStreamReader.ReadToEnd().Trim();
 
G

Guest

You need to view source. The target of the form tag's POST directive is

<form method="post" action="OffQryRedirector.jsp"

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top