有可能吗?那怎么样?
var client = new RestClient("http://localhost:58746");
var request = new RestRequest("Users/Login", Method.POST);
request.AddParameter("UserName", "user");
request.AddParameter("Password", "12345");
request.AddParameter("RememberMe", true);
request.AddParameter("ReturnUrl", "http://localhost:58746");
if (response.StatusCode == HttpStatusCode.OK)
{
var cookie = response.Cookies.FirstOrDefault(x => x.Name == FormsAuthentication.FormsCookieName); // yeah but that will not get the cookie.
}
如何获取该Cookie?
答案 0 :(得分:1)
我能够以这种方式工作:
var cookie = response.Cookies.FirstOrDefault(x => x.Name == FormsAuthentication.FormsCookieName);