我可以将缓存行添加到global.asax吗?以下代码行在c#asp.net文件中运行良好:Response.Cache.SetExpires(DateTime.Now.AddSeconds(300));Response.Cache.SetCacheability(HttpCacheability.Public);我可以在global.asax中执行此操作作为设置这些的某种方式,以便默认情况下我的整个应用程序将支持300秒的公共缓存?是的,你可以这样做,可能是protectedvoidApplication_PreRequestHandlerExecute(HttpApplicationsender,EventArgse){stringsExtentionOfThisFile=System.IO.Path.GetExtension(HttpContext.Current.Request.Path);如果(sExtentionOfThisFile.EndsWith("aspx",true,System.Globalization.CultureInfo.InvariantCulture)||sExtentionOfThisFile.EndsWith("ashx",true,System.Globalization.CultureInfo.InvariantCulture)||)){Response.Cache.SetExpires(DateTime.Now.AddSeconds(300));Response.Cache.SetCacheability(HttpCacheability.Public);但是你不能轻易删除......如果任何页面需要它。(我已经包含了一个页面测试,但只是为了看看,如果你赢得了所有这个标题,你可以选择并测试。)以上是C#学习教程:CanIaddmycachelinetoglobal.asax?如果所有分享的内容对你有用,需要进一步了解C#学习教程,希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
