dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.37k stars 9.99k forks source link

[dotnet-sdk-8.0.100-preview.7.23364.32] Fail to launch BootstrapBlazor page with System.InvalidOperationException #49511

Closed Junjun-zhao closed 1 year ago

Junjun-zhao commented 1 year ago

Is there an existing issue for this?

Describe the bug

When run the 3rd party real world app with latest build dotnet-sdk-8.0.100-preview.7.23364.32, it failed with System.InvalidOperationException

Expected Behavior

The application page could be launched successfully.

Steps To Reproduce

Minimal Repro steps (Demo attached):

  1. Create a Blazor Server project.
  2. Copy the following code to Counter.razor.

    <div>
    <EditForm Model="MyModel">
        EditForm1
    </EditForm>
    <EditForm Model="MyModel">
        EditForm1
    </EditForm>
    </div>
    @code {
    
    ExampleModel MyModel;
    protected override void OnInitialized()
    {
        base.OnInitialized();
        MyModel = new ExampleModel { Name = "test" };
    }
    public class ExampleModel
    {
        public string? Name { get; set; }
    }
    }
  3. Build the project.
  4. Change the runtime.config file to let the app run against with dotnet-sdk-8.0.100-preview.7.23364.32
    "frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "8.0.0-preview.7.23364.3"
      },
      {
        "name": "Microsoft.AspNetCore.App",
        "version": "8.0.0-preview.7.23364.1"
      }
    ]
  5. Launch the demo app.
  6. Go to http://localhost:5204/counter.

Exceptions (if any)

The error displayed on the page is as follows:

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: There is more than one named event with the name ''. Ensure named events have unique names. The following components both use this name:
 - SSRRenderModeBoundary > App > Router > RouteView > LayoutView > MainLayout > TestPage > TestComponent > EditForm
 - SSRRenderModeBoundary > App > Router > RouteView > LayoutView > MainLayout > TestPage > TestComponent > EditForm
         at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.UpdateNamedEvents(RenderBatch& renderBatch)
         at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.UpdateDisplayAsync(RenderBatch& renderBatch)
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment)
         at Microsoft.AspNetCore.Components.Endpoints.SSRRenderModeBoundary.SetParametersAsync(ParameterView parameters)
         at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters)
         at Microsoft.AspNetCore.Components.HtmlRendering.Infrastructure.StaticHtmlRenderer.BeginRenderingComponent(IComponent component, ParameterView initialParameters)
         at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.<>c__DisplayClass25_0.<PrerenderComponentAsync>b__0()
         at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c__10`1.<InvokeAsync>b__10_0(Object state)
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.PrerenderComponentAsync(HttpContext httpContext, Type componentType, IComponentRenderMode prerenderMode, ParameterView parameters, Boolean waitForQuiescence)
         at Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)
         at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, Int32 i, Int32 count)
         at BlazorApp1.Pages.Pages__Host.ExecuteAsync() in C:\Users\v-yibiaozhu\Desktop\BlazorApp1\Pages\_Host.cshtml:line 8
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts)
         at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor.ExecuteAsync(ViewContext viewContext, String contentType, Nullable`1 statusCode)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeResultAsync>g__Logged|22_0(ResourceInvoker invoker, IActionResult result)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
         at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)

.NET Version

dotnet-sdk-8.0.100-preview.7.23364.32

Anything else?

dotnet --info

.NET SDK:
 Version:8.0.100-preview.7.23364.32
 Commit:    ca467d68c8

Runtime Environment:
 OS Name:     Windows
 OS Version:10.0.19045
 OS Platform: Windows
 RID: win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\8.0.100-preview.7.23364.32\

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:8.0.0-preview.7.23364.3
  Architecture: x64
  Commit:       ae99bb2e7a

.NET SDKs installed:
  8.0.100-preview.7.23364.32 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.0-preview.7.23364.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.0-preview.7.23364.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.0-preview.7.23363.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Findings:

1) This issue repro when we have multiple EditForm in page 2) When we open Counter page by clicking from menu item on the left side, not Repro 3) If we type the URL and navigate to page, it is Repro

@dotnet-actwx-bot @dotnet/compat

Junjun-zhao commented 1 year ago

@mkArtakMSFT This bug was found in .NET 8 Preview 7 validation, could you please help check whether it is a blocker for Preview 7. Thanks.

Junjun-zhao commented 1 year ago

This bug has been fixed on the latest build dotnet-sdk-8.0.100-preview.7.23375.2, closing it.