question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blazor server doesn't render pages properly with custom WebApplicationOptions

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

If I use the following code snippet in Program.cs:

    var builder = WebApplication.CreateBuilder(new WebApplicationOptions
    {
        ApplicationName = typeof(Program).Assembly.FullName,
        ContentRootPath = Path.GetFullPath(Directory.GetCurrentDirectory()),
        WebRootPath = "wwwroot",
        Args = args
    });

Blazor server doesn’t show the web page properly.

Expected Behavior

Blazor server renders the pages properly with custom WebApplicationOptions.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

6.0.9, 6.0.109

Anything else?

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
javiercncommented, Oct 10, 2022

@khteh It’s not obvious to us what is going on here (hence why we marked the issue as investigate).

We will schedule the issue to be looked at in a future milestone based on our triage (To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.) and will provide an update at that point.

A repro project would help to make sure that we can reproduce your exact issue and determine if there is a bug in the framework or a configuration error in the application.

0reactions
MackinnonBuckcommented, Oct 31, 2022

@khteh Glad your issue was resolved!

How does that affect the application’s CSS?

By default, ApplicationName is used to resolve the static web assets manifest file, i.e. <ApplicationName>.staticwebassets.runtime.json. So, using typeof(Program).Assembly.FullName effectively causes the manifest file name to be resolved to something like <assembly name>, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.staticwebassets.runtime.json, which is incorrect. This will cause all requests to static web assets to 404, including CSS files.

Closing this as by-design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Net 6 Blazor Server-Side CSS Isolation not working
I tried builder.WebHost.UseStaticWebAssets(); on my Program.cs and that didn't work, it errors out on runtime with: "System.
Read more >
blazor web app does not render properly · Issue #48714
The new project, OneSite.WebApp, renders the download page properly and displays it. The code is exactly the same. The problem arose when I ......
Read more >
Custom UI template doesn't work in blazor-server
I have created a blazor server project and wanted to change the default UI template and use another admin dashboard bootstrap template (LEMA ......
Read more >
How to start a blazor server from another application.
Due to this I want to deliver the Blazor UI part as a plug-in. I already have a few plug-ins that are non...
Read more >
Render the Blazor Server App in IE11 Browser in Blazor
Learn here all about how to Render the Blazor Server App in IE11 Browser in Blazor ... The Microsoft Internet Explorer doesn't support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found