从 Windows Phone 中的 HttpWebResponse 标头读取 HttpOnly Cookie
有没有办法从 Windows Phone 中的 HttpWebResponse 标头读取 HttpOnly Cookie?
在我下面的代码中 “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 });
}
}
}
Is there any way to read HttpOnly Cookies from Headers of HttpWebResponse in Windows Phone?
In my code below "Set-Cookie" is not present 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 });
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,您无法直接访问 HttpOnly cookie。
您可以使用 CookieContainer 将它们传递给不同的请求,但您无法读取它们。
Unfortunately you cannot access HttpOnly cookies directly.
You can pass them to different requests using a CookieContainer, but you cannot read them.