我想在客户端浏览器中缓存主页。
但是在设置ResponseCache属性之后,响应头被设置为Cache-Control: no-cache,no-store。
在阅读了Response cache not working in asp.net core project和ResponseCache not working in net core 3.1之后,我无法修复这个问题
[ResponseCache(Duration = 300)]
public class HomeModel : PageModel
{
public const string PageName = "Home";
public void OnGet()
{
}
}

发布于 2021-09-01 07:53:36
因为我在_layout.cshtml中为搜索字段添加了一个表单,其中自动生成了一个反伪造令牌!
ASP.net核心集缓存控制:不缓存,不存储每页包含一个防伪字段或具有授权属性!
通过将此表单从_layout.cshtml中移出,解决了问题!
https://stackoverflow.com/questions/69009216
复制相似问题