2
我有一个使用Web服务的Windows Phone 7应用程序。在登录服务中,它会返回一个基于.NET表单身份验证的会话ID,该表单使用会话cookie。在使用Web服务的Windows Phone 7中,响应cookie为空
但在我的Windows Phone 7应用程序响应cookie为空,所以我无法在我的应用程序中维护会话。
这是我的代码,它发送POST请求登录服务
var serviceUrl = new Uri("https://www.bypost.com/api/login");
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(serviceUrl);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
#region
var container = new CookieContainer();
container.Add(serviceUrl, new Cookie("abc", "xyz"));
webRequest.CookieContainer = container;
#endregion
webRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), webRequest);
Console.Write("data sent");
这里是我的响应代码: HttpWebRequest的的WebRequest =(HttpWebRequest的)asynchronousResult.AsyncState; HttpWebResponse响应;
response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult);
foreach (Cookie cook in response.Cookies)
{
Console.WriteLine(cook);
}
但我的回应.Cookies返回null。
感谢您的回复...我使用的webservices支持HttpOnly,并且我们无法查看cookie –