Hi
I have created a REST web service using ASP.NET core web api. When i tried to use it, it is just getting out of function (not even throwing an error). I have read that Rest web services don't need to be published. Is it true?
BTW,
this is my code for the Web service consumption, i will appreciate it if you can tell me where i am wrong.
string strUriGetusers = "https://localhost:49391/api/user/getusers"; using (var objClient = new HttpClient()) { response = await objClient.GetStringAsync(strUriGetusers); var UserList = JsonConvert.DeserializeObject<List<User>>(response); UserCollection = new ObservableCollection<User>(UserList); }
Hi,
i found the answer after a long R&D and feel silly for such an easy answer.
the line should be
response = await objClient.GetStringAsync(strUriGetusers).Results;
Answers
You can debug locally: https://devblogs.microsoft.com/xamarin/debug-local-asp-net-core-web-apis-android-emulators/
Hi James,
Thanks for the quick reply. My web services is running nicely. "https://localhost:49391/api/user/getusers" gives me desired list of users in a list i.e. IEnumerable as the return type.
But while in the xamarin project , when i start to debug , the debug pointer comes upto the line for
response = await objClient.GetStringAsync(strUriGetusers);
Then, the debug stops and application is closed.
i thought it might be because i didn't publish it. Do you think that is the reason? or is it something else?
Hi, just as an update, i published it and still not working. it is coming out of function at the same line.
Hi,
i found the answer after a long R&D and feel silly for such an easy answer.
the line should be
response = await objClient.GetStringAsync(strUriGetusers).Results;