[研究]ASP.NET WebForm 網站 HCL AppScan 10.18.0 報告【低】【找到可快取的 SSL 頁面】弱點,如何處理?(三).aspx檔案
2025-07-14
********************************************************************************方法一、個別 .aspx.cs 網頁中 Page_Load 中設定
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
}
|
方法二、全域 Global.asxa.cs 中設定
protected void Application_BeginRequest(object sender, EventArgs e)
{
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoStore();
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
}
|
(完)

沒有留言:
張貼留言