Reading HttpOnly Cookies from HttpWebResponse Headers on Windows Phone

Is there a way to read HttpOnly Cookies from the HttpWebResponse headers in Windows Phone?

In my code below, "Set-Cookie" is not in response.Cookies []

My code

HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;

        // End the get response operation
        using (HttpWebResponse response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult))
        {
            Stream streamResponse = response.GetResponseStream();

            // But Set-Cookie is not present here as its HttpOnly
            var cookies = response.Cookies["Set-Cookie"];

            using (StreamReader streamReader = new StreamReader(streamResponse))
            {
                String Response = streamReader.ReadToEnd();
                streamResponse.Close();
                streamReader.Close();
                response.Close();

                // Call the response callback
                if (Callback != null)
                {
                    Callback(this, new EventArgs1() { Response = Response, Cookie = cookies });
                }
            }
        }
+3
source share
1 answer

Unfortunately, you cannot access the HttpOnly files directly. You can pass them to other requests using the CookieContainer, but you cannot read them.

CookieContainer container = new CookieContainer();

HttpWebRequest request = CreateRequest();

request.CookieContainer = container;

//do some requests
+3
source

All Articles