I am creating my first WindowsPhone 8.1 application, the role of my application is to create a connection to the server to receive information from it, so I write code for this process by sending a json-rpc request to the server, to get some I can get it for the first time, but when I send the second request, I get a blank response with error 404 (page not found). But when I call the service without https (only http), it works fine, no matter how many times I call it!
public async Task<string> GetDataFromServer(string urlToCall, string JSONData,string RR) { string UserName = "XXXXXXX" string Password = "XXX"; using ( var handler = new HttpClientHandler()) { handler.Credentials = new NetworkCredential(UserName, Password); HttpClient client = new HttpClient(handler); HttpResponseMessage response = null; try { response = await client.PostAsync(urlToCall, new StringContent(JSONData.ToString(), Encoding.UTF8, " application/json")); string res = response.Content.ReadAsStringAsync().Result; Windows.UI.Popups.MessageDialog g = new Windows.UI.Popups.MessageDialog(res); await g.ShowAsync(); return res; } catch (Exception ex) { Windows.UI.Popups.MessageDialog g = new Windows.UI.Popups.MessageDialog("Error is : " + ex.Message); g.ShowAsync(); return "Error"; } finally { response.Dispose(); client.CancelPendingRequests(); client.Dispose(); handler.Dispose(); } } }
Again, when the service url is called (first with https), I received a response with the requested data, but the second time I get an empty response with an error of 404 (page not found) !! Any help please
json json-rpc windows-phone-8
Bashar abu shamaa
source share