J
Jay Douglas
I am trying to do an HTTP POST to a webpage from a DLL. The webpage is
easily called, and a response is given. However, the web page is not
receiving the POSTed variables. None of them. Request.Form returns no
values. I have been over and over examples and have attempted to break my
code down to nothing. As of right now, I'm using the example just how I
found it, and still am having no luck. I'm using the .net framework v1.1.
Please advise.
EXAMPLE:
string lcUrl = "http://localhost/HTMLPDFWeb/testform.aspx";
HttpWebRequest loHttp =
(HttpWebRequest) WebRequest.Create(lcUrl);
// *** Send any POST data
string lcPostData =
"Name=" + HttpUtility.UrlEncode("Name") +
"&Company=" + HttpUtility.UrlEncode("Company");
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
easily called, and a response is given. However, the web page is not
receiving the POSTed variables. None of them. Request.Form returns no
values. I have been over and over examples and have attempted to break my
code down to nothing. As of right now, I'm using the example just how I
found it, and still am having no luck. I'm using the .net framework v1.1.
Please advise.
EXAMPLE:
string lcUrl = "http://localhost/HTMLPDFWeb/testform.aspx";
HttpWebRequest loHttp =
(HttpWebRequest) WebRequest.Create(lcUrl);
// *** Send any POST data
string lcPostData =
"Name=" + HttpUtility.UrlEncode("Name") +
"&Company=" + HttpUtility.UrlEncode("Company");
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);
loHttp.ContentLength = lbPostBuffer.Length;
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();