473,387 Members | 1,891 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,387 software developers and data experts.

WebRequest/WebResponse classes

Hi,

I'm quite new in C# so it can be a silly question, but i can't figure
how to make a req/resp and a second req with first response's
informations... What I mean:

I have no problem in sending a request to a web server, and getting
response from it, reading headers, cookies, body etc... but how can i
make a seconde request using the first communication with HttpWebRequest
and HttpWebResponse.

What exactly i am trying to do is:
connect to the server X,
get a response and cookie information,
send username email and password to X/login.php with POST data and
appropriate cookies...
get a OK message,
just 4 step
thanks a lot
PS: any tutorial about the subject would be appreciated
Nov 16 '05 #1
2 1850
For cookies, you need to instantiate a CookieContainer class and
assign the object to the CookieContainer property of all the
WebRequest object needing to share the cookies.

As for the rest of the response, do you need data inside of input
fields to POST back? The only way to really do this is to scrape it
out using RegEx or String.IndexOf.

I have some examples here:
http://odetocode.com/Articles/162.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 11 Nov 2004 03:07:05 +0200, Ziphyre <no****@yahoo.com> wrote:
Hi,

I'm quite new in C# so it can be a silly question, but i can't figure
how to make a req/resp and a second req with first response's
informations... What I mean:

I have no problem in sending a request to a web server, and getting
response from it, reading headers, cookies, body etc... but how can i
make a seconde request using the first communication with HttpWebRequest
and HttpWebResponse.

What exactly i am trying to do is:
connect to the server X,
get a response and cookie information,
send username email and password to X/login.php with POST data and
appropriate cookies...
get a OK message,
just 4 step
thanks a lot
PS: any tutorial about the subject would be appreciated


Nov 16 '05 #2
Thanks,
useful examples...
Scott Allen wrote:
For cookies, you need to instantiate a CookieContainer class and
assign the object to the CookieContainer property of all the
WebRequest object needing to share the cookies.

As for the rest of the response, do you need data inside of input
fields to POST back? The only way to really do this is to scrape it
out using RegEx or String.IndexOf.

I have some examples here:
http://odetocode.com/Articles/162.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Thu, 11 Nov 2004 03:07:05 +0200, Ziphyre <no****@yahoo.com> wrote:

Hi,

I'm quite new in C# so it can be a silly question, but i can't figure
how to make a req/resp and a second req with first response's
informations... What I mean:

I have no problem in sending a request to a web server, and getting
response from it, reading headers, cookies, body etc... but how can i
make a seconde request using the first communication with HttpWebRequest
and HttpWebResponse.

What exactly i am trying to do is:
connect to the server X,
get a response and cookie information,
send username email and password to X/login.php with POST data and
appropriate cookies...
get a OK message,
just 4 step
thanks a lot
PS: any tutorial about the subject would be appreciated


Nov 16 '05 #3

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

Similar topics

2
by: gizmo | last post by:
Hi, I'm using the following code to request the html source from the quoted site. ...... string url = "http://www1.soccerstand.com/"; WebRequest webRequest = WebRequest.Create(url);...
3
by: Paul | last post by:
Hello, First I want to refer to the problem "WebRequest : execute a button" of a few days ago. The way I solved it, I loose my session, and as a consequence my session variables. I don't want...
8
by: John K. | last post by:
Hi I was wondering if it's possible to use the WebRequest class to access a file on windows shared folder with authentication? If yes, what would the syntax be? I've tried to look this up in the...
0
by: IronYuppie | last post by:
Hi all-- I'm retrieving contents from my site using the retrieving images from the database method listed here: ...
12
by: ThyRock | last post by:
I am working on a WebRequest accessing the US Postal Service WebTools test API. This service uses a DLL file (ShippingAPITest.dll) with a query string which includes XML. The web service accepts...
0
by: Gordon | last post by:
I use the following code to get source HTML. The second line seems to work when I get no response from a site. However, I want to stop the request if it's taking more than 20 - 30 seconds. I can't...
4
by: Savas Ates | last post by:
I have a vb.net web application. I want to post some variables to another web page and take some values back and process them. This is codes in my target url. I should post "langpair" cariable...
2
by: kkb | last post by:
Hello! First, I'm sorry because of my english... I'll try to be understandable! I've got a strange problem using .NET 2003 C# and I haven't figured it out for a long time. I'm implementing an...
1
by: Mr Flibble | last post by:
OK I logon to a web site and I manage to get an SMSESSION cookie that I then store in a variable called _session (a class scoping variable). I do this by calling a logon URL and setting a cookie...
2
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
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...

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.