0

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; } } 
4
  • are you using forms authentication? Commented May 12, 2014 at 18:56
  • No, I dont set FormsAuthentication. and I dont know FormsAuthentication. this project code is made VS2013 IDE default Web API4 code. Commented May 12, 2014 at 19:02
  • Do you mean you want it to include caching? Because the response you sent doesn't Commented May 12, 2014 at 19:23
  • 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" Commented May 12, 2014 at 19:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.