可以通过以下代码示例解决Asp.net缓存在IIS上无法工作的问题:
在IIS管理器中打开网站的高级设置。在输出缓存中启用缓存,并将互联网信息服务(IIS)版本升级为最新版本。
在应用程序的Global.asax文件中添加以下代码:
protected void Application_BeginRequest(Object sender, EventArgs e) { HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(1)); HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public); HttpContext.Current.Response.Cache.SetValidUntilExpires(true); }
通过以上方法,应该可以解决Asp.net缓存在IIS上无法工作的问题。