Skip to content

[.NET 8 RC2] HttpContext is null in Login.razor (Identity scaffold) with InteractiveServer globally enabled #51422

@DM-98

Description

@DM-98

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I created a template with InteractiveServer globally enabled in the VS Template (with no sample pages) as well as Individual Accounts enabled.

I navigate to /Account/Login with the chrome URL and press Enter. It works, I guess because it's a new request and HttpContext is possible to get this way.

When I create an a href="/Account/Login"-button in Home.razor - and pressing the button... It causes an exception because Login.razor OnInitialized method uses HttpContext without null-checking it (default!).

Note: Adding data-enhance-nav="false" in my a href in Home.razor doesn't work either.

Expected Behavior

I expect to navigate to Login with a href button without any exceptions.

Steps To Reproduce

  1. Create Blazor Web App
  2. Choose Individual Accounts
  3. Choose InteractiveServer
  4. Choose Globally
  5. Make an a href="/Account/Login"-button in Home.razor
  6. Press the button
  7. Exception occurs

Exceptions (if any)

System.NullReferenceException: 'Object reference not set to an instance of an object.'

BlazorApp14.Components.Pages.Account.Login.HttpContext.get returned null.

.NET Version

8.0.100-rc.2.23502.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions