473,401 Members | 2,139 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,401 software developers and data experts.

How to make a Http request from a .net window form application

I have a .net window form application but I have to get
data from various web sites. How do I make Http request
(preferrably via post method) from a window form to get
the data from those web sites?
What namespace and dll do I have to include?
A walkthrough and coding example will be helpful.
...

Nov 16 '05 #1
1 5519
edx
> I have a .net window form application but I have to get
data from various web sites. How do I make Http request
(preferrably via post method) from a window form to get
the data from those web sites?
What namespace and dll do I have to include?
A walkthrough and coding example will be helpful.

Hi,

This is a sample that I have done recently:

Namespace of the types is:

using namespace System::Net;

System::Net::HttpWebRequest *Request =

__try_cast <System::Net::HttpWebRequest *>

(System::Net::HttpWebRequest::Create (Shttp://www.somesite.com));

String *Content, *Identifier;

// Do the actual request

//

String *Query = "IDENT=";

Query = String::Concat (Query, Ident);

Query = String::Concat (Query, "&USERLOGID=");

Query = String::Concat (Query, UserLogid);

Query = String::Concat (Query,
"&ENTRYLENGTH=-1&EXTRAINPUT=&EXTRAINPUTLENGTH=-1&ENTRY=");

Query = String::Concat (Query, Question);

Request->Method = S"POST";

Request->ContentType = S"application/x-www-form-urlencoded;
charset=\"utf-8\"";

Request->ContentLength = Query->Length;

StreamWriter *sw = new StreamWriter (Request->GetRequestStream ());

sw->Write (Query);

sw->Close ();

WebResponse *Response;

try {

Response = Request->GetResponse ();

} catch (Exception *) {

p->GetIdent ();

return;

}

Content = (new StreamReader (Response->GetResponseStream ()))->ReadToEnd ();

Content contains the response of the webserver.

I hope that helped,
Felix Arends
Nov 16 '05 #2

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

Similar topics

8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
1
by: Matt | last post by:
My problem is when the user click the submit button, it will launch another new window for the request page. I want to confirm we cannot use JavaScript open window functions to open a request page?...
3
by: nicholas4 | last post by:
I'm trying to make a web page where a form lets you enter a url address in a field and upon clicking the submit button, the text of the source code of the page is displayed below the form. I know...
7
by: kaburke | last post by:
Is there a way to make a page at the receiving end of a Server.Transfer think that the request is a Postback? (When I say "think it is a Postback," I mean I want the page to go through the ENTIRE...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
0
DressageRider
by: DressageRider | last post by:
I need your help. Desperately. Someone has to be able to fix the utter balls up I've made after dinking around in Flash for the last four days. I have no prior knowledge of anything other than...
11
by: Simon van Beek | last post by:
Dear reader, By opening an application I get always the main Access window with the closing cross in the above right corner. Is there a possibility to make this closing cross invisible? ...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.