Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
防止web缓存引发异常ASP.NET的方法?_Asp.net_Security_Http - Fatal编程技术网

防止web缓存引发异常ASP.NET的方法?

防止web缓存引发异常ASP.NET的方法?,asp.net,security,http,Asp.net,Security,Http,我正在尝试使用ASP.NET中的以下代码段停止网页缓存,但是它不起作用,并向我显示以下错误 Response.CacheControl = "no-store"; Response.AddHeader("Pragma", "no-cache"); Response.Expires = -1; 以下是我得到的一个例外 异常详细信息: System.ArgumentException:属性 CacheControl的值无效。 值=没有存储 在看起来“无存储”的位置读取是有效值,但仍然存在此错误。有

我正在尝试使用ASP.NET中的以下代码段停止网页缓存,但是它不起作用,并向我显示以下错误

Response.CacheControl = "no-store";
Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
以下是我得到的一个例外

异常详细信息: System.ArgumentException:属性 CacheControl的值无效。 值=没有存储

在看起来“无存储”的位置读取是有效值,但仍然存在此错误。有人能帮忙吗

谢谢,

试试这个:

Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

该帮助页看起来像是asp参考页,而不是asp.net参考页

您需要的页面表明有效值与httpcacheability枚举匹配。见下页:


特别是你想要的价值,我猜是NoCache。尽管您必须阅读帮助,以确保它确实是您想要的帮助。

我想您已经根据文档尝试了“无店铺”(大写N)?这也是一篇有用的文章: