I am using ASP.Net Core 8 WebApp. when you open the website, sometimes css and js files not loading and when you see console, all of them has error 500. after you reload the page, all of them load correctly.
what is the problem???
by the way it’s a simple company website and it doesn’t have a lot of c# code for rendering. most of it is static html. it is hosted on shared hosting (Plesk) and sql server 2022. it is not sql problem because this problem existed before any database creation. I searched for this problem and found that maybe this is a server problem or server is on high load! but I don’t think so. because as I mentioned earlier, It doesn’t have heavy process. just a simple webpage. I can see this problem even on pages that has no code and just return View()
by the way I should mention that all the HTML codes loads and just css and js files not loading correctly and with a reload, all loads correctly
middlewares:
app.UseWebOptimizer();
app.UseHttpsRedirection();
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = ctx =>
{
var path = ctx.File.PhysicalPath ?? "";
if (path.EndsWith(".woff2") || path.EndsWith(".webp") || path.EndsWith(".png") || path.EndsWith(".jpeg") || path.EndsWith(".jpg"))
{
ctx.Context.Response.Headers.Append("Cache-Control", "max-age=31536000,immutable");
}
}
});
app.UseResponseCompression();
you can see it on this url: bineshdev.com
this is what it looks like: