Web service working fine in Android but not in IOS RRS feed

  • Question

  • User325400 posted

    Hi Guys, I have created simple project which invokes asmx web service in json format,

    and error is_ "500, ReasonPhrase: 'Internal Server Error"_

    the web service is working fine for Android and getting results in Android emulator, but the same code is working for IOS can you please help me to resolve this

    Here is the code public async void GetCategories() { if (NetworkCheck.IsInternet()) {

                    var client = new System.Net.Http.HttpClient();
                    var formcontent = new FormUrlEncodedContent(new[]
                    new KeyValuePair<string,string>("StrCustomerID","C001"),
                    new KeyValuePair<string, string>("StrCustomerPwd","12345")
                    categorylist ObjContactList = new categorylist();
                    var response = await client.PostAsync("http://localhost/mynewservice/WebService.asmx/GetCategories",formcontent);
                    if (response.IsSuccessStatusCode)
                        string Categoryjson = await response.Content.ReadAsStringAsync();
                        if (Categoryjson != "" && Categoryjson != "Invalid Entry")
                            //Converting JSON Array Objects into generic list  
                            ObjContactList = JsonConvert.DeserializeObject<categorylist>(Categoryjson);
                        //Binding listview with server response    
                        listviewcategories.ItemsSource = ObjContactList.Table;
                        await DisplayAlert("JSONParsing", "No network is available.", "Ok");
                    //Hide loader after server response    
                    ProgressLoader.IsVisible = false;
    Tuesday, June 20, 2017 6:36 AM

All replies

  • User76916 posted

    @DarshanJS - the most likely reason is due to your url of localhost. Check if you can reach the website in the iOS simulator in the browser.

    Tuesday, June 20, 2017 6:55 AM
  • User325400 posted

    @AdamP said: Yes Sir, i can browse in that IOS simulator, actually other projects are working fine in same IOS simulator, But the web service i have created for other projects in C# language but this i have created in VB.Net, Whether that may be the issue,

    Tuesday, June 20, 2017 8:01 AM
  • User263 posted

    Check your app transport security exceptions. https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

    Tuesday, June 20, 2017 10:30 AM
  • User235903 posted

    Hi @DarshanJS

    Try this in Info.plist in your Project:


    For reference go through this image it is from Info.plist in my project

    for more details: https://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9

    Let me know if you have any doubts further ThankYou.

    Wednesday, June 21, 2017 4:10 AM
  • User325400 posted

    @VenkataSivaprasadReddyPulagam said: Dude i am not getting that option itself in my project only, can you guide me to navigate to that settings

    Wednesday, June 21, 2017 4:52 AM
  • User235903 posted

    Hi @DarshanJS ,

    download the attachment below, I am sending you Images with Step-by-Step Tutorial to set NSAppSecurity

    Let me know if you have any doubts Thank you

    Wednesday, June 21, 2017 5:37 AM
  • User325400 posted

    @AdamP said: i got a very strange solution Initially i have created the web service by coding in VB.Net and that was giving internal server error only in IOS and the method is SqlCmd.CommandText = SqlStrQuery.ToString ObjDB.GetDataSet(dsData, SqlCmd)

                HttpContext.Current.Response.Output.Write((JsonConvert.SerializeObject(dsData, Newtonsoft.Json.Formatting.Indented)))

    Then i created same web method in c# it is working fine both in IOS and Android and the code is

    SqlDataAdapter sda = new SqlDataAdapter(strsql, ConfigurationManager.ConnectionStrings["BTConString"].ToString());
                DataSet das = new DataSet();
                Context.Response.Output.Write(JsonConvert.SerializeObject(das, Newtonsoft.Json.Formatting.Indented));
                return string.Empty;

    Can you notice what is wrong in VB.Net code?

    Wednesday, June 21, 2017 7:09 AM
  • User325400 posted

    @Velocity said: Check your app transport security exceptions. https://ste.vn/2015/06/10/configuring-app-transport-security-ios-9-osx-10-11/

    By referring some solutions i came to know that no need to set exceptions after IOS 9 and if you are using Enterprise version.

    Wednesday, June 21, 2017 7:12 AM
  • User325400 posted

    Above issue got resolved by adding below code in web config file in Web service

      <compilation debug="true" strict="false" explicit="true" targetFramework="4.5.2" />
      <httpRuntime targetFramework="4.5.2" />
          <add name="HttpGet"/>
          <add name="HttpPost"/>
    Thursday, June 22, 2017 5:22 AM