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 9004509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:54:44+00:00 2026-06-16T00:54:44+00:00

I am thoroughly confused as to what is the problem here. My understanding of

  • 0

I am thoroughly confused as to what is the problem here. My understanding of the CookieContainer must be totally wrong. I am trying to log in to a website hosted on my machine. I have fiddler set up as a proxy, so I am able to read the traffic.

Every time I try to view the cookies on windows phone, the cookie container is always empty. I have tried so many different things to be able to get that container filled, but everything has failed. This is the last thing I tried:

        CookieContainer cc = new CookieContainer();
        HttpWebRequest request = WebRequest.CreateHttp("http://localhost:8888/account/logon");
        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";
        request.CookieContainer = cc;
        request.BeginGetRequestStream(streamResult =>
        {
            HttpWebRequest xR = streamResult.AsyncState as HttpWebRequest;
            Stream stream = xR.EndGetRequestStream(streamResult);
            StreamWriter sw = new StreamWriter(stream);
            sw.Write("username=user1&password=1111");
            sw.Close();

            xR.BeginGetResponse(responseResult =>
            {
                HttpWebRequest yR = responseResult.AsyncState as HttpWebRequest;
                HttpWebResponse response = yR.EndGetResponse(responseResult) as HttpWebResponse;
                response.Close();

                Dispatcher.BeginInvoke(() => MessageBox.Show("cc count: " + cc.Count.ToString() + "\nresponse count: " + response.Cookies.Count));
            }, xR);

        }, request);

However, if I use the exact same code in a console app, the container “cc” has the cookies!

        CookieContainer cc = new CookieContainer();
        HttpWebRequest request = WebRequest.CreateHttp("http://localhost:8888/account/logon");
        request.ContentType = "application/x-www-form-urlencoded";
        request.Method = "POST";
        request.CookieContainer = cc;
        request.BeginGetRequestStream(streamResul =>
        {
            HttpWebRequest xR = streamResul.AsyncState as HttpWebRequest;
            Stream stream = xR.EndGetRequestStream(streamResul);
            StreamWriter sw = new StreamWriter(stream);
            sw.Write("username=user1&password=1111");
            sw.Close();

            xR.BeginGetResponse(responseResult =>
            {
                HttpWebRequest yR = responseResult.AsyncState as HttpWebRequest;
                HttpWebResponse response = yR.EndGetResponse(responseResult) as HttpWebResponse;
                response.Close();

                Console.WriteLine("cc count: {0}\nresponse count: {1}", cc.Count.ToString(), response.Cookies.Count);
            }, xR);

        }, request);

        Console.Read();

The server is sending back both cookies that I am looking for each time I test it. However for whatever reason, the windows phone code does not get those cookies. This is pretty much the same as this question: Cannot get cookies in wp7 using HttpWebRequest however I don’t understand what the solution was.

  • 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-06-16T00:54:45+00:00Added an answer on June 16, 2026 at 12:54 am

    Wow, I feel like a fool. It has been working all along… Maybe to others this is obvious, but I missed it. The problem is that since the cookies that are being sent back are HttpOnly, the cookie container does not expose them at all, even if you ask for the count of cookies.

    It is strange though that in the console version, I can see that there are two, but I suppose the System.Net.dll for windows phone locked down the CookieContainer a little more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This section has me thoroughly confused. I have an example problem that I am
Eric Lippert's comments in this question have left me thoroughly confused. What is the
I'm thoroughly confused. Here's my code: use strict; use warnings; use Test::More; subtest 'huh?'
I have been thoroughly confused by CodePlex and the TFS services it offers or
I am trying to automate my deployment process and am now thoroughly confused. I
In Short I am thoroughly confused by the array of SQL Server services available,
This is thoroughly confusing me. I am trying to gather very basic statistics on
I have looked thoroughly, but I have not found the solution (or perhaps I
I have an app which was tested thoroughly and working fine on Android Gingerbread
I'm creating a website and as I am thoroughly enjoying using SASS/Compass for organizing

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.