You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using rest sharp in NET MAUI application development, for the same API call that is supposed to inject a cookie, in Android you will see the cookie but it is missing when running in iOS device.
Code Sample:
async Task TestCookiesAsync(){
var restClient = new RestSharp.RestClient(new RestSharp.RestClientOptions()
{
BaseUrl = new Uri("https://google.com"),
CookieContainer = new System.Net.CookieContainer()
});
var request = new RestSharp.RestRequest("", RestSharp.Method.Get);
var response = await restClient.ExecuteAsync(request);
Console.WriteLine(response.Cookies.Count);
}
Expected behaviour:
The response cookie should be added inside the cookie container.
OS: iOS 17.2.1 (iPhone 11 )
NET MAUI .NET 8
Rest Sharp V 110.2.0
The text was updated successfully, but these errors were encountered:
This probably has something to do with the differences between the native handlers on iOS vs Android.
i.e. Xamarin.Android.Net.AndroidMessageHandler, Mono.Android vs System.Net.Http.NSUrlSessionHandler, Microsoft.iOS
If a redirect is involved, it might be related to #2059, although I wonder why the behavior would differ between mobile platforms. :(
Thank you for your response and looking into the post.
In fact I do not suspect the issue comes from those handlers because eventually due to the cookie issue I had with Restsharp, I replaced it with the native HttpClient and it works fine on both platforms.
I put an example of the working code below.
When using rest sharp in NET MAUI application development, for the same API call that is supposed to inject a cookie, in Android you will see the cookie but it is missing when running in iOS device.
Code Sample:
Expected behaviour:
The response cookie should be added inside the cookie container.
The text was updated successfully, but these errors were encountered: