473,545 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5525
> 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.


This is a sample that I have done recently:

Namespace of the types is:

using namespace System::Net;

System::Net::Ht tpWebRequest *Request =

__try_cast <System::Net::H ttpWebRequest *>

(System::Net::H ttpWebRequest:: Create (Shttp://www.somesite.co m));

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,

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

Request->Method = S"POST";

Request->ContentType = S"applicatio n/x-www-form-urlencoded;

Request->ContentLengt h = Query->Length;

StreamWriter *sw = new StreamWriter (Request->GetRequestStre am ());

sw->Write (Query);

sw->Close ();

WebResponse *Response;

try {

Response = Request->GetResponse ();

} catch (Exception *) {

p->GetIdent ();



Content = (new StreamReader (Response->GetResponseStr eam ()))->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

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 Request" was the original error msg now that I reinstalled iislockdown and urscan I get "The parameter is incorrect." If I use the get method with this...
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? The following page2.asp won't output the value entered in page1.asp. However, if we do <form action="page2.asp" method="get" target="_blank">, then...
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 it'll have to make a url connection in javascript but I don't how to do this. Please help.
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 event sequence for a postback, including LoadViewState, ProcessPostData, etc.) Even when Sever.Transfer transfers a page to itself (i.e., Page A.aspx...
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 the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still...
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 a button EDIT ,which when user clicks directs him to another page (done.asp). Now the problem is that from this page (done.asp) if he clicks on the...
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 how to point and click, so I figured the fastest way to get comfortable with both Flash and Dreamweaver was to immerse myself in them and see how fast...
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? All the settings in the Start-up form under Tools are disabled but the closing cross in the above right corner is still visible.
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 on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or...
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.