【问题标题】:Restsharp on WP 7.1 adding cookiesRestsharp 在 WP 7.1 上添加 cookie
【发布时间】:2012-02-04 02:32:07
【问题描述】:

我正在尝试使用 RestSharp 将 cookie 添加到请求中,但在 fiddler2 中我没有在请求中看到 cookie,并且服务调用失败。向 RestRequest 添加 cookie 有什么技巧吗?

 RestRequest rq = new RestRequest(LTV.NowNext(), Method.GET);
        rc.AddDefaultParameter(LTV.cookie.Key, LTV.cookie.Value, ParameterType.Cookie);

        rc.ExecuteAsync<LTV.nowNext>(rq, (response2) =>
        {
            if (response2.Data == null)
                return;
            foreach (LTV.channel channel in response2.Data.channels)
                this.Items.Add(new ItemViewModel() { LineOne = channel.name, LineTwo = channel.showing[0].content[0].parent.title, LineThree = channel.showing[1].content[0].parent.title });
        });

谢谢, 铝

【问题讨论】:

  • 嗯,我已经测试了 AddDefaultParameter 和 AddParameter,它在 fiddler 中运行良好。什么是 LTV.NowNext() 与 LTV.nowNext?
  • LTV.NowNext() 是 URI 路径,LTV.nowNext 是结果对象——基本上是我糟糕且缺乏想象力的命名结构

标签: c# windows-phone-7 restsharp


【解决方案1】:

在向 RestRequest 添加 cookie 时,RestSharp 在 Windows Phone 上有一个错误!

我解决了这个问题,并有一个pull request 等待他们集成到主分支。

目前,您可以通过使用 AddHeader("Cookie", cookieValuesString)...

来解决这个问题

【讨论】:

  • 更新:我的修复已经进入RestSharp主分支,所以下个版本修复了这个问题!
猜你喜欢
  • 1970-01-01
  • 2012-06-02
  • 2010-09-30
  • 1970-01-01
  • 2014-07-01
  • 1970-01-01
  • 1970-01-01
  • 2013-05-11
  • 1970-01-01
相关资源
最近更新 更多