Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top