2010-12-07 66 views
0

我想登录到一个网站,通过Windows Phone 7应用程序发送短信。我有2个提供商工作,但当我尝试沃达丰我遇到了一个错误。网站不返回饼干

从我收集的内容看来,响应似乎不包含cookie,或者它们没有被读取。请求登录成功,我返回的响应是正确的页面,但不包含cookie。

的网址:

RequestUrl = String.Format("https://www.vodafone.ie/myv/services/login/Login.shtml?username={0}&password={1}", userSettings.Username, userSettings.Password), 

的请求:

 Request = (HttpWebRequest)WebRequest.Create((requestCollection.CurrentRequest().RequestUrl)); 

     if (Request.CookieContainer == null) 
     { 
      Request.CookieContainer = cookieJar.CookieContainer; 
      Request.AllowAutoRedirect = true; 
      Request.AllowReadStreamBuffering = true; 
      Request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5.0.6"; 
     } 

当代码中的错误作为响应cookie无法评价:

public void AddCookiesToContainer(HttpWebResponse response) 
    { 
     CookieCollection.Add(response.Cookies); 
     CookieContainer.Add(response.ResponseUri, CookieCollection); 
    } 

及以下的调试器显示没有饼干:(

alt text

alt text

alt text

+0

没有人有任何建议吗? :( – deanvmc 2010-12-07 16:35:56

+0

CookieCollection = new CookieCollection(); – deanvmc 2010-12-07 18:35:34

回答

1

代码的哪些行有错误?

您是否已验证服务确实会返回Cookie? (即,如果您从PC发出相同请求)

编辑:
远程主机正在返回Cookie,重定向到索引页面,但在该页面中没有响应中的cookie。这可以解释为什么当您尝试使用它时,集合中没有Cookie。

验证对PC客户端的这种行为,检查来自index.jsp的响应正文,这可能包含帮助调试和检查过程应该如何工作的文档的信息。