我正在尝试使用 RestSharp 在 WinPhone 7 Mango 的 RestClients 和应用程序会话之间获取一个 cookie。
如果我使用单个 RestClient 实例,则 cookie 会持续存在。我希望 cookie 在 RestClient 实例和用户返回应用程序之间持续存在。
我正在尝试使用 RestSharp 在 WinPhone 7 Mango 的 RestClients 和应用程序会话之间获取一个 cookie。
如果我使用单个 RestClient 实例,则 cookie 会持续存在。我希望 cookie 在 RestClient 实例和用户返回应用程序之间持续存在。
RestSharp 最近添加了自动 cookie 支持!
RestSharp 102.4+ 支持对来自同一个 IRestClient 的所有请求使用共享的 System.Net.CookieContainer。通过这样做,响应中设置或取消设置的任何 cookie 都将在后续请求中使用。为了使用共享的 CookieContainer,只需在使用前设置 RestClient 实例的属性:
var client = new RestClient ("http://server/");
client.CookieContainer = new System.Net.CookieContainer();
您需要手动保存 cookie 信息,RestSharp 中不支持在会话之间保存 cookie。