开发者

How does one set multiple cache-control directives in ASP.NET

开发者 https://www.devze.com 2022-12-31 17:23 出处:网络
I have to have several certain cache-control directives set on an ASP.NET page in order to pass a Hailstorm security scan. For example, it wants me to have

I have to have several certain cache-control directives set on an ASP.NET page in order to pass a Hailstorm security scan. For example, it wants me to have

Cache-control: no-cache="set-cookie"

in addition to

Cache-control: no-cache

I have been setting the latter with 开发者_Go百科the following line in my C# codebehind:

Response.CacheControl = "no-cache";

Is there a special way to indicate both directives at once? Do I just separate them with a semicolon?


You can do this in the OnInit event like this:

  protected override void OnInit(EventArgs e)
        {
            Response.CacheControl = "no-cache"; 

            base.OnInit(e);
        }

Maybe a good idea to create HttpModule for this purpose.

0

精彩评论

暂无评论...
验证码 换一张
取 消