Blocking against static files (css/js)
See original GitHub issueI am just getting started using the middleware, and I’m coming across some blocking notes against our html/css files. I am not sure how this should be handled. Any direction?
ASP.NET Core 3.1
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2.0 GET https://localhost:44307/login
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint 'WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc)'
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[3]
Route matched with {area = "Account", action = "Login", controller = "Auth"}. Executing controller action with signature Microsoft.AspNetCore.Mvc.IActionResult Login(System.String, System.String) on controller WebMvc.Areas.Account.Controllers.AuthController (WebMvc).
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[1]
Executing action method WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc) - Validation state: Valid
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action method WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc), returned result Microsoft.AspNetCore.Mvc.ViewResult in 0.0505ms.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[1]
Executing ViewResult, running view Login.
info: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor[4]
Executed ViewResult - view Login executed in 5.4982ms.
info: Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker[2]
Executed action WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc) in 9.9739ms
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint 'WebMvc.Areas.Account.Controllers.AuthController.Login (WebMvc)'
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2.0 GET https://localhost:44307/css/Site.css?v=637231648404436533
warn: Ben.Diagnostics.BlockingMonitor[6]
Blocking method has been invoked and blocked, this can lead to threadpool starvation.
at System.IO.FileStream.ReadAsyncInternal(Memory`1 destination, CancellationToken cancellationToken, Int32& synchronousResult)
at System.IO.FileStream.ReadAsyncTask(Byte[] array, Int32 offset, Int32 count, CancellationToken cancellationToken)
at System.IO.FileStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Http.StreamCopyOperationInternal.CopyToAsync(Stream source, Stream destination, Nullable`1 count, Int32 bufferSize, CancellationToken cancel)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext(Thread threadPoolThread)
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.MoveNext()
at System.Runtime.CompilerServices.TaskAwaiter.<>c.<OutputWaitEtwEvents>b__12_0(Action innerContinuation, Task innerTask)
at System.Threading.Tasks.AwaitTaskContinuation.System.Threading.IThreadPoolWorkItem.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/css/Site.css'. Physical path: 'C:\dev\WebMvc\wwwroot\css\Site.css'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 47.1026ms 200 text/css
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2.0 GET https://localhost:44307/js/site.js?v=637231648404439536
info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]
Sending file. Request path: '/js/site.js'. Physical path: 'C:\dev\wagt\WebMvc\wwwroot\js\site.js'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 72.4794ms 200 application/javascript
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 306.2087ms 200 text/html; charset=utf-8
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/2.0 POST https://localhost:44307/profiler/results application/json 835
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished in 233.0392ms 200 application/json
Here’s the Configure method.
public void Configure(IApplicationBuilder app)
{
app.UseBlockingDetection();
if (Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
app.UseExceptionHandler("/error");
app.UseStatusCodePagesWithRedirects("/error/{0}");
}
app.UseHttpsRedirection();
app.UseSession();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseMiniProfiler();
// app custom
app.UseMaintenanceMiddleware();
app.UseLegacyRedirectMiddleware();
app.UseRequestRefreshClaimsMiddleware();
app.UseEndpoints(delegate (IEndpointRouteBuilder endpoints)
{
endpoints.MapControllerRoute("areaRoute", "{area:exists}/{controller=Dashboard}/{action=Index}/{id?}");
endpoints.MapDefaultControllerRoute();
});
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Prevent static files inside a CSS from being displayed ...
You could style the body element to hide the content then use the window.onload event to remove it so any glitches are hidden....
Read more >9 tricks to eliminate render blocking resources
Render blocking resources are static files, such as fonts, HTML, CSS, and JavaScript files, that are vital to the process of rendering a...
Read more >Can't load css and js files from static directory. was blocked ...
Can't load css and js files from static directory. was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
Read more >How to Eliminate Render-Blocking Resources on WordPress
Render-blocking resources can be CSS and JavaScript files. They're named render-blocking resources because they slow down the rendering of the page. At the...
Read more >"was blocked due to MIME type (“text/html”) mismatch ...
Static files (javscript and css) not loading: "was blocked due to MIME type (“text/html”) mismatch". Hi! I got my webapp up and running...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d raise that in https://github.com/dotnet/aspnetcore the
System.Text.Json
serializer may fare better thanNewtonsoft.Json
; though you need to check your outputs/inputs when changing as it has caveats like it only serializes properties not fields etc@benaadams @stephentoub
Sorry if this isn’t the right place, but I’m starting here cause of the blocking detector package.
I’m running in to another scenario that seems to be pointing back to the same IO issue. I have an ASP.NET Core 3.1 API returning a complex object (multiple objects as properties all of which recursively may have children objects). As it stands on my dev box (IIS Express, i7-6700k, 32GB RAM), the response of the request is triggering another blocking detector.
The response data of the request is 62KB. I am returning a
new JsonResult(myObj)
. I’ve found when intentionally clearing one of the large properties on the response, it takes me down to 12KB and no buffering takes place. Am I hitting a JSON.NET object/ASP.NET response size limit?Edit - looks like 30KB is the limit before it buffers to disk?
I see 32 instances of this blocker detected. Here are only the top couple lines of the stack trace.