简体   繁体   中英

How to implement HTTP 1.0 / 1.1 in ASP.NET

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM