huinalam
huinalam

Reputation: 23

I want that HttpResponse header do not include Set-Cookie

Client makes a GET request, here's api response:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 26
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/8.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=636f48abd1e4ad4818a02dc087a9bd0c1be56fb972e821c7c8cf37553bc46cc3;Path=/;Domain=testtest11.azurewebsites.net
Date: Sun, 13 Apr 2014 19:57:08 GMT
Connection: close

I want the response header do not include

"Cache-Control", "Pragma", "Expires", "Server", "X-AspNet-Version", "Set-Cookie"

In other words, I hope that the ideal Response.

HTTP/1.1 200 OK
Pragma: no-cache
Content-Length: 26
Content-Type: application/json; charset=utf-8
Date: Sun, 13 Apr 2014 19:57:08 GMT
Connection: close

how i can do?

example asp.net web api code:

public class ProductsController : ApiController
{
    public HttpResponseMessage GetProduct(string id)
    {
        HttpResponseMessage respMessage = new HttpResponseMessage();
        respMessage.Headers.Clear();
        respMessage.Content = new ObjectContent<string[]>(new string[] { "value22", "value2" }, new JsonMediaTypeFormatter());
        return respMessage;
    }
}

Upvotes: 0

Views: 597

Answers (1)

Yishai Galatzer
Yishai Galatzer

Reputation: 8862

Start with this article: http://www.strathweb.com/2012/05/output-caching-in-asp-net-web-api/

Web API doesn't support Output Cache in the box, filip made a pretty good library for it.

Upvotes: 1

Related Questions