Reputation: 1350
I'm integrating with an sso system that requires setting a cookie during a POST operation. I don't see any way to do this using an HttpResponseMessage. I could take a dependency on HttpResponseBase in my controller, but that seems very ghetto. Any other way to do this?
Upvotes: 1
Views: 2457
Reputation: 13089
You could return a Set-Cookie-Header
using the Headers-Collection of the HttpResponseMessage
.
Upvotes: 1
Reputation: 3704
Per this discussion, this is now a bit easier:
public HttpResponseMessage Post(int id, [FromBody]string value) {
var result = this.Request.CreateResponse();
result.Headers.AddCookies(new[] { new CookieHeaderValue("name", "value") });
return result;
}
They keep changing this type of stuff though... (further reading)
Upvotes: 3