Skip to content

First time navigation doesn't fire enhancedload or DOMContentLoaded events when page is loaded. #59780

Open
@htmlsplash

Description

@htmlsplash

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Environment:
.net 9
Blazor Static SSR page
Visual Studio: 17.12.3

When navigating to a page for the first time using a simple hyperlink the wired up event handlers to DOMContentLoaded or enhancedload are not invoked, ie. one of these should run, but neither runs.

Blazor.addEventListener('enhancedload', () => {
	console.log('enhancedload!');
});

document.addEventListener('DOMContentLoaded', function() {
	console.log('Document is fully loaded!');
});

To view the event handler trace, you need to open dev tools console.

To reproduce:
Go to this repo: https://github.com/htmlsplash/BlazorWebAppTest
Launch project
Open browser dev console
Select "Nav test 1" option from the left nav.
Check the console to see traces.
The source page of interest for this bug report is: NavTest1.razor

NOTE;
This bug is very tricky to reproduce. If you do observe the traces, select "Home" link, press F5 (while on the home page), then go back and select Nav test 1 option.

UPDATE 1:
Read my update comments below.

Expected Behavior

One of the registered handlers for DOMContentLoaded or enhancedload should be invoked.

Steps To Reproduce

See problem description.

Exceptions (if any)

No response

.NET Version

.net 9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsThis issue tracks updating documentationarea-blazorIncludes: Blazor, Razor Components

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions