Forum Xamarin.Forms

How to connect localhost of windows to iphone simulator in mac

saishaiksaishaik INMember ✭✭

I have xamarin.forms application for iOS and local database is created in sql server 2012 on windows 10,now i am trying to connect the localhost to the of windows to the iphone simulator.

i tried : Connecting through IP address of the windows Pc.

Connected mac and windows under same wifi.

Disabled firewall.

none of them worked.

The code i am trying to connect is:
private string Uri = "";//Windows Ip address:localhost port number
private string GetDishesUrl = "api/DishDetails/GetDishDetails?id=5";
var httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri(Uri);

            var response = await httpClient.GetAsync(new Uri(Uri + GetDishesUrl));

            var stringAsync = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
                var responseJson = stringAsync;

                return JsonConvert.DeserializeObject<List<DishDetails>>(responseJson);
        catch(Exception ex)
            return null;

when i disabled firewall and trying to connect to mac then i am getting responseas null and also the exception also as null and in safari while giving Ip address along with GetDishesUrl getting as Bad Request-Invalid Hostname,How to acheive this local host connection? I already placed this this but i did get it to be worked.

Sign In or Register to comment.