I have an Owin Test Server:
using (var testServer = TestServer.Create<TestPipelineConfiguration>())
using (var client = new HttpClient(testServer.Handler))
{
client
.DefaultRequestHeaders
.Add("Cookie", $"{AspNetCookies}=HeyThere;");
client.BaseAddress = new Uri("https://testserver/");
var message = client
.PostAsync("print", new StringContent(
jsonProvider.SerialiseObject(new
{
Url = "https://some/url"
}),
Encoding.UTF8, "application/json"))
.Result;
//var message = client.GetAsync("test").Result;
message
.StatusCode
.ShouldBeEquivalentTo(HttpStatusCode.OK);
}
I want to set other properties on that cookie, like HttpOnly
, Secure
and Domain
.
Is this possible?
Cookie is a header with list of key-value items. In your code it will look like this:
.Add("Cookie", "cookie1=value1;cookie2=value2")
Properties are part of the cookie value, semicolon separated, e.g. "Cookie=cookievalue; path=/; HttpOnly"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With