小编aos*_*aos的帖子

例外:无法从依赖项生成etag

我有一个IHttpHandlerASP.NET,它提供一些图像.处理程序按以下方式设置ETAG:

context.Response.AddFileDependency(filename);                
context.Response.Cache.SetLastModifiedFromFileDependencies();
context.Response.Cache.SetETagFromFileDependencies();
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetMaxAge(new TimeSpan(999,0,0,0));
context.Response.Cache.SetSlidingExpiration(true);
context.Response.Cache.SetValidUntilExpires(true);                
context.Response.Cache.VaryByParams["*"] = true;
byte[] buffer = File.ReadAllBytes(filename);
context.Response.ContentType = MimeMapping.GetMimeMapping(mi.Mi_filename);
context.Response.StatusCode = 200;
context.Response.BinaryWrite(buffer);
Run Code Online (Sandbox Code Playgroud)

有时System.Web.HttpException在IIS7下得到一个Exception,它说:

无法从依赖项生成etag.其中一个依赖项无法生成唯一ID.

但我无法重现问题(我知道我无法使用ASP.NET内部测试Web服务器测试它).有谁知道为什么会发生这种情况以及我可以采取哪些措施来防止这种情况发生?

c# asp.net iis-7

5
推荐指数
1
解决办法
663
查看次数

标签 统计

asp.net ×1

c# ×1

iis-7 ×1