You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a Blazor app running .NET 8 on a Windows Server published through Visual Studios IIS publish option.
We used WebOptimizer in our Program.cs and then started noticing that
After Successful Publishing the webpage thats been opened by Visual Studio does not display any styles or scripts (F12 shows that the files are not delivered by the server 404|500)
Devices like phones that open a link to this blazor app for the first time will also fail to load the script and styles
When reloading the page (F5) the styles and scripts can be loaded
After some digging in the Windows Error logs i saw several errors popping up for each of the failed files that the browser tried to download.
Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware
EventId: 1
SpanId: 2ea13da234f83e9f
TraceId: 54fdcae62c87d46c65c9a3e720204362
ParentId: 0000000000000000
RequestId: 800005f7-0000-ef00-b63f-84710c7967bb
RequestPath: /css/app.min.css
An unhandled exception has occurred while executing the request.
Exception:
System.UnauthorizedAccessException: Access to the path 'C:\inetpub\sites\<IIS_PROJECT_FOLDER>\obj\WebOptimizerCache' is denied.
at System.IO.FileSystem.CreateDirectory(String fullPath, Byte[] securityDescriptor)
at System.IO.Directory.CreateDirectory(String path)
at WebOptimizer.AssetResponseStore.AddAsync(String bucket, String cachekey, AssetResponse assetResponse)
at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options)
at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options)
at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<Invoke>g__Awaited|10_0(ExceptionHandlerMiddlewareImpl middleware, HttpContext context, Task task)
This causes a chain reaction and prevents the download of all files.
The published Blazor page does not contain an \obj\WebOptimizerCache folder and WebOptimizer fails to create this folder.
FIX:
Manually adding this folder solves all the problems but i wonder what is causing this because the IIS User has all the permissions required. If this is all expected behaviour the documentation should be updated and reflect that it is necessary to create this folder structure to use the WebOptimizer.
The text was updated successfully, but these errors were encountered:
My first time using this library and I hit the same issue today. I'm using the latest version of everything. After creating the missing path the error goes away and the site becomes usable.
Strange note: No cache files are ever created there! So it's throwing an unrecoverable error that crashes the site for all users and then it's not even using the cache folder. I would not consider this exceptional. It needs to log the error and then have a graceful fallback to a different method. Especially when this folder isn't in use!
I have the same on Plesk Shared Hosting (Not blazor, Asp.Net Core MVC 8). I asked server and CDN supportand they didn't found any error and told me that my code has problem. but I wonder What is the problem! I searched everywhere and then for testing, I commented WebOptimizer from program.cs and everything works fine. a fix would be nice!
Here is the Image after the user opens the page for the first time, no matter desktop or mobile user:
as you can see HTML is rendered and images and other static files loaded except CSS and JS files with error 500. After reloading everything is going to be fine and fast.
another thing I found is that after IIS Idle timeout, this problem happens again for the users. (because it's going to start again)
Hello!
We have a Blazor app running .NET 8 on a Windows Server published through Visual Studios IIS publish option.
We used WebOptimizer in our Program.cs and then started noticing that
After some digging in the Windows Error logs i saw several errors popping up for each of the failed files that the browser tried to download.
App.razor:
<link rel="stylesheet" href="/css/app.min.css" />
Example for app.min.css
This causes a chain reaction and prevents the download of all files.
The published Blazor page does not contain an \obj\WebOptimizerCache folder and WebOptimizer fails to create this folder.
FIX:
Manually adding this folder solves all the problems but i wonder what is causing this because the IIS User has all the permissions required. If this is all expected behaviour the documentation should be updated and reflect that it is necessary to create this folder structure to use the WebOptimizer.
The text was updated successfully, but these errors were encountered: