Open VictorioBerra opened 3 years ago
It appears that setting enableDiskCache
to false
fixes the issue. Does it make sense to do that?
Maybe better is to set cacheDirectory
to directory with read/write permitions for app.
I think the default for cacheDirectory
is invalid. It points into the web app's content root (If later fixed, I've found it in this commit
)
A production web application should not have write access on its own directory, that would open security concerns.
To add write access only to the default <contentRoot>/obj
folder would need the deployment set up properly.
That's unnecessary extra work.
Why not just use the web application's temp folder?
@nvirth Do web apps have temp folders they can write to by default in IIS?
I think yes. But I'm not sure. But then I can't remember setting up any folder credentials for HttpPostedFileBase
to work in the old ASP.NET MVC. That saves the uploaded files into a temporary folder - maybe it's the Temporary ASP.NET Files
folder somewhere, don't really know that.
Anyway, I just fixed the issue in my project with a custom MyWebOptimizerConfig : IConfigureOptions<WebOptimizerOptions>
implementation. In this I set CacheDirectory
to Path.GetTempPath()
. I applied it this way:
services.AddWebOptimizer(...);
services.Remove(services.Single(s => s.ServiceType == typeof(IConfigureOptions<WebOptimizerOptions>)));
services.AddTransient<IConfigureOptions<WebOptimizerOptions>, MyWebOptimizerConfig>();
@VictorioBerra Path.GetTempPath()
does not always work. On one of our new test servers, we've seen this log now: System.UnauthorizedAccessException: Access to the path 'C:\Windows\TEMP' is denied.
We also experience the same issue.
Seeing the same error as the OP, for an ASP.NET 8 web app running in IIS, WebOptimizer version 3.0.405
This happens during IIS cold starts.
<PackageReference Include="LigerShark.WebOptimizer.Core" Version="3.0.304" />
<PackageReference Include="LigerShark.WebOptimizer.Sass" Version="3.0.43-beta" />
Startup - WebOpt Configuration
Startup - Configure
Error