D
Dino Chiesa [Microsoft]
If what you want to do is programmatically post to a web page, then
System.Net.WebRequest will do it.
This is not VB.NET, but you get the idea:
private static string PostURI(string URI, string Parameters)
{
string CommandURI = URI;
WebRequest myWebRequest = WebRequest.Create(CommandURI);
//needed only if outbound traffic must go through a proxy server
//WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
//myWebRequest.Proxy = proxyObject;
myWebRequest.ContentType = "application/x-www-form-urlencoded";
myWebRequest.Method = "POST";
byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
myWebRequest.ContentLength = bytes.Length;
Stream OutputStream = myWebRequest.GetRequestStream ();
OutputStream.Write (bytes, 0, bytes.Length);
OutputStream.Close ();
WebResponse MyWebResponse = myWebRequest.GetResponse();
Stream MyStream = MyWebResponse.GetResponseStream();
StreamReader MyStreamReader = new StreamReader(MyStream);
return MyStreamReader.ReadToEnd().Trim();
}
usage:
String sPostData= "Argument1=" + sData + "&Argument2=SomethingElse";
String sResultHtml= PostURI("http://server/something/something",
sPostData);
System.Net.WebRequest will do it.
This is not VB.NET, but you get the idea:
private static string PostURI(string URI, string Parameters)
{
string CommandURI = URI;
WebRequest myWebRequest = WebRequest.Create(CommandURI);
//needed only if outbound traffic must go through a proxy server
//WebProxy proxyObject = new WebProxy("http://proxyserver:80/",true);
//myWebRequest.Proxy = proxyObject;
myWebRequest.ContentType = "application/x-www-form-urlencoded";
myWebRequest.Method = "POST";
byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
myWebRequest.ContentLength = bytes.Length;
Stream OutputStream = myWebRequest.GetRequestStream ();
OutputStream.Write (bytes, 0, bytes.Length);
OutputStream.Close ();
WebResponse MyWebResponse = myWebRequest.GetResponse();
Stream MyStream = MyWebResponse.GetResponseStream();
StreamReader MyStreamReader = new StreamReader(MyStream);
return MyStreamReader.ReadToEnd().Trim();
}
usage:
String sPostData= "Argument1=" + sData + "&Argument2=SomethingElse";
String sResultHtml= PostURI("http://server/something/something",
sPostData);