I am trying to use C# HttpClient class to send Http Get message with cookies.
HttpClient.GetAsync
just accepts URL. So, I cannot use that method.
I found that HttpClient.SendAsync
method let me send cookies in following way.
HttpRequestMessage GETRequest = new HttpRequestMessage(HttpMethod.Get, completeUrl);
GETRequest.Content = new FormUrlEncodedContent(formVals);
HttpResponseMessage GETResponse = client.SendAsync(GETRequest).Result;
But when executed, it fails saying -
"Cannot send a content-body with this verb-type"
I know that Get messages are ideally for getting and not for Posting data. But in my situation, the cookie is stored on client to save client preferences and I have to send them to client through Http Get message (through HttpClient class).
I don't want to reinitialize HttpClient object; that will change its SessionID. I don't want to add content to Get message. I am just asking is there is any other way to update Get message cookie with additional values.
Please advise me how do I deal with this problem. Thanks for your help in advance.