有没有办法从Windows Phone中的HttpWebResponse标题中读取HttpOnly Cookies?
在我的代码中" Set-Cookie" 不在 response.Cookies []
中我的代码
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 });
}
}
}
答案 0 :(得分:3)
很遗憾,您无法直接访问HttpOnly Cookie。 您可以使用CookieContainer将它们传递给不同的请求,但您无法读取它们。
CookieContainer container = new CookieContainer();
HttpWebRequest request = CreateRequest();
request.CookieContainer = container;
//do some requests