Reputation: 11
I am building Windows 8.1 Application and using Windows.Web.HTTP.HTTPClient API to talk with a custom SSO Login service. It redirects from HTTPs to HTTP. It was working fine with System.Net.HTTP. HTTPClient API however it is giving exception with Windows.Web.HTTP.HTTPClient API.
I am getting the exception - "The text associated with this error code could not be found.\r\n\r\nA redirect request will change a secure to a non-secure connection\r\n"
Code Snippet
var baseFilter = new HttpBaseProtocolFilter();
baseFilter.AllowAutoRedirect = true;
var httpClient = new HttpClient(baseFilter)
serverURI = new Uri("https://sso.rumba.int.pearsoncmg.com/sso/loginService?service=http://www.google.com?authservice=rumbasso&username=may23_rumba_edu1&password=pass&gateway=true");
HttpResponseMessage response = await httpClient.GetAsync(serverURI);
Please advise what I can do to fix this issue.
Upvotes: 1
Views: 1133
Reputation: 401
As a workaround you could disable auto-redirect and perform the redirect manually.
var filter = new HttpBaseProtocolFilter();
filter.AllowAutoRedirect = false;
var client = new HttpClient(filter);
var response = await client.GetAsync("the url");
var location = response.Headers["location"];
response = await client.GetAsync(new Uri(location)).AsTask(cancellationToken, progress);
return await response.Content.ReadAsBufferAsync();
Hope it helps, Please let me know if you found a smarter solution.
Alvaro.
Upvotes: 1