如果您从操作方法中删除该OutputCache
属性,它会起作用吗?
//[OutputCache(NoStore = true, Duration = 60, VaryByParam = "*")]
public ActionResult profile()
{
usertb user = db.usertbs.SingleOrDefault(a => a.EMail == userid);
return View(user );
}
如果是这样,您应该能够通过 2 个步骤解决此问题。首先,把它放在你的 Global.asax 文件中:
public override string GetVaryByCustomString(HttpContext context, string custom)
{
return "User".Equals(custom, StringComparison.OrdinalIgnoreCase)
? User.Identity.Name
: base.GetVaryByCustomString(context, custom);
}
之后,您可以OutputCache
在操作中使用以下属性:
[OutputCache(NoStore = true, Duration = 60, VaryByCustom = "User")]
public ActionResult profile()
{
usertb user = db.usertbs.SingleOrDefault(a => a.EMail == userid);
return View(user );
}