Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

HttpClient Different Implementations?

$
0
0

Hello!

When developing my project on Xamarin, I first test some code in Windows Console and only then, test on Android. The current tested code was to do some http requests to a NTLM-based server. So, I'm trying to do some WebDAV requests, (use method PROPFIND etc.) and a weird behavior appears.

To make the WebDAV's requests, I use the HttpMethod class and HttClient.SendAsync() to send my request.

On the Console, the code works fine, the NTLM authentication process occurs without a problem.

But, when tested on Xamarin Forms, Android platform, my app does the request, the server responds with 401 (Unauthorized) and my app does not complete the NTLM challenge.

I must add that, using the HttpClient.GetAsync() method works fine on both platforms!

Has anyone knows why? Does Xamarin have a different implementation for HttpClient when compiling? What should I do? here's the code:

    public async Task<string> PropFindAsync(string _url, int _depth = 0, int _timeOutSeconds = 20)
    {
        string content = "";

        connection.Timeout = new TimeSpan(0, 0, _timeOutSeconds);
        var method = new HttpMethod("PROPFIND");
        var request = new HttpRequestMessage(method, _url);
        request.Headers.Add("Prefer", "return-minimal");
        request.Headers.Add("Depth", string.Format("{0}", _depth));
        request.Headers.Add("Translate", "f");
        var response = await connection.SendAsync(request);
        CheckStatusCode(response.StatusCode);
        content = await response.Content.ReadAsStringAsync();
        return content;
    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>