Note that there are some explanatory texts on larger screens.

plurals
  1. PORestSharp on Windows Phone no set-cookie in response
    primarykey
    data
    text
    <p>I have a problem with using the RestSharp client on the Windows Phone device. Starting form the beginning, I have the ASP.NET Web Api service hosted online. I have a request user address: POST: <a href="http://my-service-url.com/token" rel="nofollow">http://my-service-url.com/token</a> where I send Email and Password as a body parameters and I get 201 status code and a cookie in the response. When I do it in fiddler everything works fine. I also have the functional test for my API which is using the RestSharp which is also working correctly: </p> <pre><code>[Given(@"I fill email and password with correct data and I click log in button")] public void GivenIFillEmailAndPasswordWithCorrectDataAndIClickLogInButton() { //Delete user if he exists _testUserHelper.DeleteTestUser(TestEmail); //Create new activated user Assert.IsTrue(_testUserHelper.CreateTestUser(TestEmail, TestPassword)); //Prepare client var client = new RestClient(CarRentalsConstants.HostAddress); var restRequest = new RestRequest("api/token", Method.POST) { RequestFormat = DataFormat.Json }; //Add parameters to request restRequest.AddBody(new { Email = TestEmail, Password = TestPassword }); //Perform request _response = client.Execute(restRequest); } [When(@"the log in login process finishes")] public void WhenTheLogInLoginProcessFinishes() { Assert.AreEqual(HttpStatusCode.Created, _response.StatusCode, _response.Content); Assert.IsNotNull(_response.Cookies.SingleOrDefault(q =&gt; q.Name == ".ASPXAUTH");); } </code></pre> <p>The one above works properly, and the cookie is in the response object.</p> <p>Now what I try to do on my windows phone looks like this:</p> <pre><code>var restRequest = new RestRequest("token", Method.POST) {RequestFormat = DataFormat.Json}; restRequest.AddBody(new {Email = email, Password = password}); myWebClient.ExecuteAsync(restRequest, (restResponse, handle) =&gt; { switch (restResponse.StatusCode) { case HttpStatusCode.Created: { var cookie = restResponse.Cookies.SingleOrDefault(q =&gt; q.Name == ".ASPXAUTH"); successLogicDelegate(cookie); } break; case HttpStatusCode.BadRequest: { HandleBadRequest(restResponse.Content, failureLogicDelegate); } break; default: msgBox.Show(StringResources.ServerConnectionError); failureLogicDelegate(null); break; } }); </code></pre> <p>And in this case, the response returns the "Created" status code, but the cookie is then set to null. I have no idea what is happening here, but I am fairly certain that server is sending this cookie, so where does it get lost?</p> <p>Any help will be really appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload