Forum General

Do i have to publish my webservice before using it

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?

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);                   

Best Answer

  • pearlshwetapearlshweta Member ✭✭
    Accepted Answer

    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;


Sign In or Register to comment.