Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS file not loading Core 3.0 #47

Closed
ChaosSlave51 opened this issue Sep 24, 2019 · 8 comments · Fixed by #48
Closed

CSS file not loading Core 3.0 #47

ChaosSlave51 opened this issue Sep 24, 2019 · 8 comments · Fixed by #48

Comments

@ChaosSlave51
Copy link

ChaosSlave51 commented Sep 24, 2019

After upgrading my project to the release of Core 3.0 the css file no longer loads and just returns an empty page.

I was able to reproduce this on the demo project in the repo just by upgrading it to core 3.0. I had to comment out

     app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

to run the project.

EDIT:
setting o.ConfigureKestrel(options => options.AllowSynchronousIO = true);
fixes the issue, but i am guessing is not a good solution

@gemon01
Copy link

gemon01 commented Oct 3, 2019

also for me the same problem, it is not loaded the stylesheet!
ho provato anche ad aggiungere:
o.ConfigureKestrel(options => options.AllowSynchronousIO = true);
ma niente ...!
immagine

@keerthirajap
Copy link

keerthirajap commented Oct 20, 2019

To be more precises for 3.0, replace in Program.cs .

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup()
.ConfigureKestrel(options =>
{
options.AllowSynchronousIO = true;
});
});

@gemon01
Copy link

gemon01 commented Oct 21, 2019

elmah

same result! The style sheet is not loaded.

@ghost
Copy link

ghost commented Oct 21, 2019

Hi!

Same problem! Any solution?

@JonBraund
Copy link

I found this problem wasn't solved by the keerthiraja1988's code snippet when using IIS with the .net core 3 hosting bundle as kestrel doesn't seem to be relevant. Instead this similar snippet worked for me in ConfigureServices in startup.cs

services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO = true; });

Hope this helps someone

@gemon01
Copy link

gemon01 commented Nov 12, 2019

I found this problem wasn't solved by the keerthiraja1988's code snippet when using IIS with the .net core 3 hosting bundle as kestrel doesn't seem to be relevant. Instead this similar snippet worked for me in ConfigureServices in startup.cs

services.Configure<IISServerOptions>(options => { options.AllowSynchronousIO = true; });

Hope this helps someone

TOP !

@Luca7993
Copy link

another solution avoiding change the AllowSynchronousIO option is to intercept the stylesheet call and serve the static css file.

in startup, in configure method use this (instead of simply app.UseElmah()):
app.MapWhen(context => context.Request.Path.StartsWithSegments("/elmah", StringComparison.OrdinalIgnoreCase), appBuilder => { appBuilder.UseMiddleware<MyMiddleware>(); appBuilder.UseElmah(); });

MyMiddleware is this:
`public class MyMiddleware
{
private readonly RequestDelegate _next;

        public MyMiddleware(RequestDelegate next)
        {
            _next = next;
        }

        public async Task Invoke(HttpContext context)
        {
            if (context.Request.Path.HasValue && context.Request.Path.Value == @"/elmah/stylesheet")
            {
                context.Response.Redirect("/css/elmah.min.css");
            }
            else
            {
                // Call the next delegate/middleware in the pipeline
                await _next(context);
            }
        }
    }`

where the path for redirect depend on where you put the static css file.
you can take the static css file using the two file Bootstrap.css and ErrorLog.css that you can find in this repository in ElmahCore/ElmahCore.mvc

@NickBranstein
Copy link

I had this same issue when using IIS so I do not think it is fully fixed. Instead of turning on SyncIO for the entire server you can combine the two above solutions and turn it off for specific requests.

app.UseWhen(context => context.Request.Path.StartsWithSegments("/elmah", StringComparison.OrdinalIgnoreCase), appBuilder =>
            {
                appBuilder.Use(next =>
                {
                    return async ctx =>
                    {
                        ctx.Features.Get<IHttpBodyControlFeature>().AllowSynchronousIO = true;

                        await next(ctx);
                    };
                });
            });

            app.UseElmah();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants