iLemming
iLemming

Reputation: 36232

Restsharp forms autentication

Is it possible? Then how?

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.
}

How to get to that cookie?

Upvotes: 0

Views: 1032

Answers (1)

Gustyn
Gustyn

Reputation: 2164

I was able to get this to work this way:

var cookie = response.Cookies.FirstOrDefault(x => x.Name == FormsAuthentication.FormsCookieName);

Upvotes: 1

Related Questions