Going crazy over HTTP Post from class library

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();
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top