Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Problems addressing a webservice

$
0
0

Guys,

I have the following code:
public async Task GetToken(string username, string password)
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(this.servername);
client.DefaultRequestHeaders.Clear();
client.Timeout = new TimeSpan(0, 1, 30);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            try
            {
                string webservice = string.Format("{0}/Webservices/FormAuthentication.svc/REST/Login?username={1}&password={2}", this.methodBeginning, username, password);
                var response = await client.GetAsync(webservice);
                if (response.IsSuccessStatusCode)
                {
                    var result = response.Content.ReadAsStringAsync().Result;
                    return result.Replace("\"", string.Empty);
                }
            }
            catch (Exception ex)
            {

            }

            return string.Empty;
        }
    }

On following piece of code, I get this error: 'Attempting to JIT compile method '(wrapper delegate-invoke) :invoke_callvirt_void_HttpWebRequest_bool (System.Net.HttpWebRequest,bool)' while running with --aot-only'

var response = await client.GetAsync(webservice);

Works fine in Android/Phone, on iOS Simulator, but not on my iPhone 5s?

Searched for hours at the internet but no conclusive answer, can please somebody help me?

Thanks!
Alain.


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>