使用 imageresizer diskcache 4.2.5 并且最近才开始出现此错误的高频率。这是在最近向我们的网站发布新代码之后。我们没有明确更改与 imageresizer 相关的知识,因此不确定它是否与新版本、web.config 问题等有关。
我们在这个 MVC 5 Web 应用程序中使用预编译视图。
这已经工作了多年。看起来我们几个月前将它的 nuget 包从 3.4.3 升级到了 4.2.5。
直接导航到图像时,不会引发错误。对我来说有趣的是试图访问文件的这个 .tmp 命名约定。
试图从 Elmah 错误日志中检索的图像路径是:C:\inetpub\wwwroot\website\Images\no_image.jpg?maxwidth=420&maxheight=420
堆栈跟踪:
System.UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\website\imagecache\0f\ae1ea13d9acc62f74c3da0f38e1b85328c07effdd1afce83d91b44f244a602f3.jpg.tmp_4a1f20d7.tmp' is denied.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at ImageResizer.Plugins.DiskCache.CustomDiskCache.<>c__DisplayClass29_0.<TryWriteFile>b__0()
at ImageResizer.Plugins.DiskCache.LockProvider.TryExecute(String key, Int32 timeoutMs, LockCallback success)
at ImageResizer.Plugins.DiskCache.CustomDiskCache.GetCachedFile(String keyBasis, String extension, ResizeImageDelegate writeCallback, Int32 timeoutMs, Boolean asynchronous)
at ImageResizer.Plugins.DiskCache.DiskCache.Process(IResponseArgs e)
at ImageResizer.Plugins.DiskCache.DiskCache.Process(HttpContext context, IResponseArgs e)
at ImageResizer.InterceptModule.HandleRequest(HttpContext context, HttpModuleRequestAssistant ra, IVirtualFile vf)
at ImageResizer.InterceptModule.CheckRequest_PostAuthorizeRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.<>c__DisplayClass285_0.<ExecuteStepImpl>b__0()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)