So i'm testing universal applications and have reached this:
I have an application on Windows Tablet that gets data from server.
Server is protected with certificate ( SSL )
I have this code, runs great on simple Windows Store Application, and Universal application project for tablet, but not Phone
async public static Task<string> GetDataFromServer()
{
try
{
HttpClientHandler aHandler = new HttpClientHandler();
aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
HttpClient aClient = new HttpClient(aHandler);
aClient.DefaultRequestHeaders.ExpectContinue = false;
aClient.DefaultRequestHeaders.MaxForwards = 3;
Uri requestUri = new Uri("MYURL");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
var result = await aClient.GetAsync(requestUri, HttpCompletionOption.ResponseContentRead);
var responseHeader = result.Headers;
var responseBody = await result.Content.ReadAsStringAsync();
return responseBody;
}
catch (Exception e)
{
return "";
}
}
All needed capabilities are set in manifest:
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="sharedUserCertificates" />
<Capability Name="privateNetworkClientServer" />
<Capability Name="internetClientServer" />
</Capabilities>
<Extensions>
<Extension Category="windows.certificates">
<Certificates>
<Certificate StoreName="Root" Content="Assets\CoolCertificate.cer" />
</Certificates>
</Extension>
Phone code - doesn't crash, no errors or warnings - just blank result.
Code: {StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:{ Content-Length: 0}} And no notification to the user like in WinRT: