문제

Let me start by showing code:

    private async Task<bool> session()
    {
        string post = " ";

        HttpContent postContent = new StringContent(
            post,
            Encoding.ASCII,
            "application/x-www-form-urlencoded");

                using (HttpResponseMessage response = await this.httpClient.PostAsync(
                    "CANT_SHARE_URL.com/data", postContent))
                using (HttpContent content = response.Content)
                {

                    this.session =content.Headers.GetValues("session").FirstOrDefault();
                }
        return true;
    }

I can't disclose the url.

The problem is that it does not set the session variable and the content has returned the headers the header is also showing up in fiddler. The exception 'System.InvalidOperationException' I've tried most obvious options it's certainly responding correctly and I somehow got the headers into a string but I can't remember how.

도움이 되었습니까?

해결책

Are you sure the session header is on the Content? Have you tried looking in the request.Headers collection?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top