How to get return value from a URL in C#?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

<code
string URL
int Status

URL = "http://www.test.org/send.asp?userid=" + userid + "&password=" + this.password
InternetExplorer ie = new InternetExplorer();
Status = ie.Navigate(URL, ref o, ref o, ref o, ref o)
</code

I need to send 2 variables to another website and that website will return a value (0 = success, 1 = fail)

However, the Navigate() is a void method.

How should I do it in C#

Thanks for help.
 
You can also look into the System.Net.WebClient ocject.

Example:
using System;
using System.Net;
using System.Web;

protected void Connect()
{
string serverUrl = null, postData = null;
byte[] myDataBuffer = null;
WebClient httpClient = new WebClient();
try
{
// Generate Post Data
postData = HttpUtility.UrlEncode( _postData ) );
// Connect to the Server.
switch ( _connectionType )
{
case CONNECTION_TYPE.GET:
serverUrl = _server + "?" + postData;
myDataBuffer = httpClient.DownloadData(serverUrl);
break;
case CONNECTION_TYPE.POST:
serverUrl = _server;

httpClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
byte[] postArray = Encoding.ASCII.GetBytes( postData );
myDataBuffer =
httpClient.UploadData(serverUrl,"POST",postArray);
break;
}
string webPageContent = Encoding.ASCII.GetString(myDataBuffer);
}
catch (Exception e)
{
throw (e);
}
}
 
Back
Top