473,545 Members | 1,924 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cookies: Are they handled by HttpWebRequest and HttpWebResponse classes?

Hi all,

I am beginnig to try out the exciting Web stuff in .NET, so please forgive
my perhaps silly question.
I am trying to communicate with a Web server using HttpWebRequest
and -Response classes from a WinForms application. The server may set and
read back cookies.

Do I have to support the server in a special way (like a browser), and if
so, where do I have to look for some documentation? Or are cookies handled
transparently?

Thanks in advance,
ulrich
Nov 18 '05 #1
3 1086
You'll need to create an instance of the CookieContainer class and
attach the container to the Cookie property before sending each
request. The CookieContainer will manage the cookies for you then.

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

On Thu, 7 Oct 2004 21:52:43 +0200, "Ulrich Sprick"
<ul***********@ gmx.de> wrote:
Hi all,

I am beginnig to try out the exciting Web stuff in .NET, so please forgive
my perhaps silly question.
I am trying to communicate with a Web server using HttpWebRequest
and -Response classes from a WinForms application. The server may set and
read back cookies.

Do I have to support the server in a special way (like a browser), and if
so, where do I have to look for some documentation? Or are cookies handled
transparentl y?

Thanks in advance,
ulrich


Nov 18 '05 #2
Umm.... I must have had my dark sunglasses on while browsing though MSDN
last night, I simply overlooked the CookieContainer property. Sorry for
that. I am looking in the right direction, am I?

Ulrich
Nov 18 '05 #3
YES! I'm on the way! Thanks for the response!
ulrich

"Scott Allen" <bitmask@[nospam].fred.net> schrieb im Newsbeitrag
news:ui******** *************** *********@4ax.c om...
You'll need to create an instance of the CookieContainer class and
attach the container to the Cookie property before sending each
request. The CookieContainer will manage the cookies for you then.

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

Nov 18 '05 #4

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

Similar topics

0
1727
by: Michael Evanchik | last post by:
Hello all, since i wanted to use ssl and its seems easy to do so with this object. Im trying to login to a webserver (aol) for this example. But for some reason, im packet sniffing with ethreal and cookies are not being sent along with the header and post data. here is the code im using. Can anyone please tell me why this is happening? I...
0
1444
by: Pat Allan | last post by:
I've spent half a day on this with no success, so I'm hoping someone can point out what I'm doing wrong. I have an ASP.NET Server-side component that I've created, and as part of its Render function, it requests another webpage (which the user defines) through an HttpWebRequest object. This page that is being called requires the cookie...
1
1838
by: Bhupesh Saini | last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page. What do I need to do to have the cookies sent along with the request Below is the code snippet from the function I an using I am using to achieve...
1
4193
by: Ravi | last post by:
Hi , i am trying to pass the same session Id to all the webrequest, but sometimes the response.cookies returns zero and sometimes one. is this to do something with cookies expire. In this sample code the line Console.WriteLine("cookies1 count : " + firstResponse.Count.ToString()); and Console.WriteLine("second Cookie : " +...
1
1786
by: Prasanna Padmanabhan | last post by:
I am writing a simple HTTP Client in .NET. I make an HTTP Request and examine the response. I get an empty CookieCollection when I do HttpWebResponse.Cookies. However HttpWebResponse.Headers returns the correct list of cookies (represented as a comma-separated string) in the response. Can someone please explain the discrepancy? Thanks,
4
10036
by: Andy Fish | last post by:
Hi, I have a web app that I want to make calls back into itself (preserving the session cookies etc). I am using a System.Net.HttpWebRequest object to make the request, but I am having trouble getting the cookies into it. In the current (i.e. incoming) request, the cookies are stored as System.Web.HttpCookie objects in a...
16
11022
by: Cheung, Jeffrey Jing-Yen | last post by:
I have a windows form application that generates a request, downloads an image, and waits the user to enter in login info. Unfortunately, this image is dynamic and based on session data. I have read documents on the CookieCollection property of HttpWebRequest. Currently, I have the functionality in my code to be able to accept cookies, and...
6
8739
by: James MA | last post by:
I'm now writing a small program to communicate a web server to simulate a web client. I use te httpwebrequest to talk with the server, and it works find for "POST" method, however, when i test other link using "GET" method, i found that the cookies data has not included in the request. Here is the sample: ' sURL is the URL of server...
7
3896
by: mcfly1204 | last post by:
I have a request to a login page, and I am trying to save the response cookies in a CookieContainer. I am then attempting to make another request reusing the previous CookieContainer. I then am trying to save the content of the second response as an .html document. However, it seems as though my second request keeps taking me back to the...
0
7410
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...
0
7923
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7437
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...
0
7773
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 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...
0
5984
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3466
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...
1
1901
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
722
bsmnconsultancy
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.