Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

connect Xamarin to rest web service

$
0
0

hi,
I'm starting learning Xamarin and i face problem in connecting app with DB. i built rest web services with method get and i uplode it in host. after that i add this code in app
public MainPage()
{
var mylist = GetlistAsync();
InitializeComponent();
}
private async Task<List> GetlistAsync()
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync("my url");
List Items = new List();
var content = await response.Content.ReadAsStringAsync();
Items = JsonConvert.DeserializeObject<List>(content);
return Items;
}
the problem is whenever i add run. the code will move to InitializeComponent after httpclint. getasync line without doing lines after it.
so i test if verified connectivity between your device/emulator and your server and it work . after that i tray to test the code in web application mvc and it works fine but when i tray it in xamarin form app it doesn't work .
pleas help as fast as possible
thanks


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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