473,322 Members | 1,431 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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

Tom
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.
Nov 16 '05 #1
3 10696
Take a look at HttpWebRequest:

http://msdn.microsoft.com/library/en...ClassTopic.asp

-Jason

Tom wrote:
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.

Nov 16 '05 #2
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);
}
}
"Jason DeFontes" <ja***@defontes.com> wrote in message
news:On**************@TK2MSFTNGP10.phx.gbl...
Take a look at HttpWebRequest:

http://msdn.microsoft.com/library/en...ClassTopic.asp
-Jason

Tom wrote:
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.

Nov 16 '05 #3
Tom
Hi

In VB6, I can use OpenURL

http://msdn.microsoft.com/library/de...enurlmethod.as

to get the return value

Which library can I use in C#

Does VB.net has that library and I can add it to C# to call a VB method?

Thanks for advice.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Neal Coombes | last post by:
Posted to comp.lang.c++.moderated with little response. Hoping for better from the unmoderated groups: -------- Original Message -------- Subject: Return appropriately by value, (smart)...
16
by: G Patel | last post by:
Hi, If I want to call functions that don't return int without declaring them, will there be any harm? I only want to assign the function(return value) to the type that it returns, so I don't...
15
by: Nerox | last post by:
Hi, If i write: #include <stdio.h> int foo(int); int main(void){ int a = 3; foo(a); }
12
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
3
by: tshad | last post by:
I am trying to set up a class to handle my database accesses. I can't seem to figure out how to get the return value from my dataReader from these routines (most of which I got elsewhere). They...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
20
by: lovecreatesbeauty | last post by:
Hello experts, Is the following code snippet legal? If it is, how can exit() do the keyword return a favor and give a return value to the main function? Can a function call (or only this...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
7
by: Terry Olsen | last post by:
How do I get this to work? It always returns False, even though I can see "This is True!" in the debug window. Do I have to invoke functions differently than subs? Private Delegate Function...
6
KoreyAusTex
by: KoreyAusTex | last post by:
If anyone can help me figure out the what the missing return statements are, I think it might be the fact that I need to add a return false in the getValue()? import java.util.*; public class...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.