Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1838704
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:31:12+00:00 2026-05-17T06:31:12+00:00

I have a pratical question here. I have to access to a site and

  • 0

I have a pratical question here.
I have to access to a site and get the cookies information to reuse it in subsequent navigation. I don’t have any browser control on my side, because everything is supposed to run on a server.
With some site the task is pretty easy, but there are some site that send back cookies in a way I cannot manage to intercept.

On example is Italian highways site: I can’t understand how they sent back cookies and most important, how can I capture those cookies from a .Net application.

I’ve tried both WebClient object, looking into header, in this way:

var wc = new WebClient();
var htmlMainPage = wc.DownloadString(new Uri(AutostradeMainSite));
string cookies = wc.ResponseHeaders["Set-Cookie"];

but I don’t get any result.
Even by looking into header, there’s no cookies there.

Then I tried with HttpWebRequest object, but I wasn’t able to retrieve the cookies:

HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(AutostradeMainSite);
wr.Method = "GET";
HttpWebResponse response = (HttpWebResponse)wr.GetResponse();
var cookies = response.Cookies

What am I doing wrong?

Analyzing the main page of the site with some developer tools for IE or Chrome, I can see that some cookies are sent to the browser, but I cannot see them neither in the header, nor in the javascript… How can it work?
Thanks in advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:31:13+00:00Added an answer on May 17, 2026 at 6:31 am

    The WebClient class can’t handle cookies out of the box, although it’s pretty easy to create a derived version that supports cookies. You can do it with the HttpWebRequest class, but you need to set the CookieContainer property:

    HttpWebRequest req = WebRequest.Create("http://www.google.com") as HttpWebRequest;
    req.CookieContainer = new CookieContainer();
    HttpWebResponse res = req.GetResponse() as HttpWebResponse;
    CookieCollection cookies = res.Cookies;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is just for a sake of knowledge. I don't have any practical
I have a question for all the programming enthusiasts out here. The pointers has
Looking for some practical advice here and any experiences people have had in a
I have a theorical/pratical question about how inheritance works in C#. Let's say that
Here's a similar question for SourceSafe . We have a single SVN repository storing
Does anyone have any practical suggestions about how to manage feature creep in GUIs?
I have similar problem to one discussed here , but with stronger practical usage.
So I have been through most of the questions here. Also quite a few
Sort of a fringy, non-practical question coming along here. You know that in Perl
So this question is a sort of follow on from here ( how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.