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
↧
connect Xamarin to rest web service
↧