How to implement HTTP 1.0 / 1.1 in ASP.NET

2.5k views Asked by At

I wanted to know the best way to implement the following in ASP.NET. I have never used these directives so if you could kindly give me a sample code, It would be really helpful.

  1. HTTP/1.0 Pragma header
  2. HTTP/1.1 Cache - Control header
  3. Backdated Expires Header
1

There are 1 answers

8
Icarus On

As you mentioned on your question, they are simply HTTP Headers. Some of these headers, for example Cache-Control were introduced with HTTP v1.1. Others were introduced since HTTP 1.0 (Pragma), etc.

All you need to do is add them to your Response via Response.AddHeader("Key","value");

For example:

Response.AddHeader("Cache-Control","public");

UPDATE Now that you provide more details...

I don't particularly see any security issues with not setting these headers on your response. What's the issue with no caching pages according to the auditing company? If anything, your website is more secure by not allowing browsers to cache your pages.

Update 2 One way to define your pragma header on the markup is to have this:

<meta http-equiv="pragma" content="no-cache">

Right after the opening <head> element of your aspx page. Similarly for all other headers.