Reputation: 29
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.
Upvotes: 0
Views: 2715
Reputation: 63956
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.
Upvotes: 1