我已经得到了JSESSIONID,我想将它添加到页眉,但我不知道在哪里添加。
Cookie jSessionID = client.ResponseCookies["JSESSIONID"];
if (jSessionID != null)
{
// JSESSIONID
sessionid = jSessionID.Value;
var settings = new ODataClientSettings()
{
UrlBase = "MyURL"
};
settings.BeforeRequest += delegate(HttpRequestMessage request)
{
String aux = String.Join(":", new String[] {"admin", "admin" });
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(aux);
request.Headers.Add("Authorization", "Basic " + System.Convert.ToBase64String(plainTextBytes));
};
var client2 = new ODataClient(settings);
}