开发者

Website not returning cookies

I am trying to log into a website to send SMS via a windows phone 7 app. I have 2 providers working but when I try Vodafone I am running into an error.

From what I gather it seems that the response does not contain cookies, or they are not being read. The request logs in ok and the response I get back is the correct page but it contains no cookies.

The Url:

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

The Request:

     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";
 开发者_如何学Go       }

Where the code errors as the response cookies could not be evaluated:

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

And below is the debugger showing no cookies :(

Website not returning cookies

Website not returning cookies

Website not returning cookies


Which line of the code has the error?

Have you verified that the service does return cookies? (i.e. If you make the same request from a PC)

Edit:
The remote host is returning cookies in it's redirection to the index page but in that page there are no cookies in the response. This would explain why there are no cookies in the collection when you try and use it.

Verify this behaviour against a PC client, inspect the body of the response from index.jsp ans this may contain information to help debug and check the documentation on how the process is supposed to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜