Skip to content

OnInit() called twice #9116

Closed
Closed
@dkurok

Description

@dkurok

Describe the bug

The OnInit()-event is called twice / handler runs twice

To Reproduce

Steps to reproduce the behavior:

  1. Visual Studio 2019; create new project using Razor components template

  2. In MainLayout.razor add the following to the end of the file:
    `@functions{ protected override void OnInit()
    {
    base.OnInit();
    Console.WriteLine("OnInit called");

    }
    }`

  3. Place a breakpoint on the Console.WriteLine-call in OnInit()

  4. Debug and see in Output -> ASP.NET Core Web Server:
    The breakpoint will be hit twice! From what I've read it should only be hit once at the initialization of the component

Expected behavior

OnInit() should only be called once

Additional context

Visual Studio Enterprise 2019 Version 16.0.0 on Windows 10, 1809

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions