jui2ce
asked on
Post FORM Automatically to another web site not on the same server. USing Asp.net/VB
I would like to post to
http://MyOtherPage.com/posthere/
What I would like to post is
Action=Login
Lang=en
User=Myuser
Password=Mypassword
http://MyOtherPage.com/posthere/
What I would like to post is
Action=Login
Lang=en
User=Myuser
Password=Mypassword
ASKER
I know this is bad but I'm really bad at transfering C to VB could you help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I use the Code aboce I get
Name 'HttpWebRequest is not declared'
It is refering to
HttpWebRequest myRequest =
Name 'HttpWebRequest is not declared'
It is refering to
HttpWebRequest myRequest =
add:
Imports System.Net;
Imports System.Net;
Try this:
using System.Text;
...
ASCIIEncoding encoding = new ASCIIEncoding();
string POSTData = "Action=Login&Lang=en&User
byte[] data = encoding.GetBytes(POSTData
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest
myRequest.Method = "POST";
myRequest.ContentType="app
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream
// Send the data.
newStream.Write(data,0,dat
newStream.Close();
If you want a response, you need to do the following (ie.. on the same cs page):
// GET THE RESPONSE FROM THE SERVER
HttpWebResponse myResponse = (HttpWebResponse)myRequest
using ( StreamReader sr = new StreamReader(myResponse.Ge
{
Response.Charset = "";
Response.ContentType = "text/HTML";
Response.Write(sr.ReadToEn
}
Hope that helps!