Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

httpclient issue in UWP

Tags:

c#

httpclient

uwp

I am using System.Net.Http.HttpClient, It is showing some weird errors.Below is my code.

public async static Task SearchYoutube(string query, int count)
{
    try
    {
        string format = "https://www.googleapis.com/youtube/v3/search?part=snippet&maxResults=20&q=mere&key=XXXXXXXXXXXXXXX&pageToken=";

        HttpClient client = new HttpClient();
        // System.Net.ServicePointManager.EnableDnsRoundRobin = true;
        var html = await client.GetStringAsync(format);
        string ht = html.ToString();
    }
    catch (Exception ex)
    {
        //var resp = ex.Response as HttpWebResponse;
    }
}

Exception- The text associated with this error code could not be found.

An error occurred in the secure channel support.

My workarounds- hrresult- -2147012739(I think this WINNETI_SCHANNEL_ERROR)

below is the stacktrace-

at System.Net.Http.HttpClientHandler.d__86.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Net.Http.HttpClient.d__58.MoveNext()

Steps I have taken to resolve the issue:

1.Turned off Firewall.

2.Given all available options in INTERNET OPTIONS(SSL,TLS etc.)

3.The link you have provided ,I have already checked that.

4.Tried Windows.Web.http instead of system.net.http

5.Used Handlers and Certificates

6.Checked capabilities-Internet(Client),Internet(Client and server) ,Private Networks(Even I checked all of the capabilities and tried but same result)

7.I have created a console application and pasted same codes,Worked like a charm.The only problem is ,it is not working in uwp platform and specifically in my system(It is working in my friend's system).

8.Tried all available option available in internet.

like image 718
uncle_scrooge Avatar asked Jan 30 '17 17:01

uncle_scrooge


1 Answers

You are probably using Windows Insider builds. Google sites don't work in Insider builds because of the current security policies that will be fixed. You can read the text for Edge here: https://mspoweruser.com/cant-access-youtube-gmail-insider-builds-microsoft-working/ but the same goes to HttpClient.

like image 197
Ivan Ičin Avatar answered Oct 06 '22 21:10

Ivan Ičin