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.44k stars 10.01k forks source link

Problems with Blazor and MVC parts after updating to .NET 6 (Matches, Compiled descriptor) #30719

Closed nono3551 closed 3 years ago

nono3551 commented 3 years ago

I wanted to upgrade .NET to latest version so my solution is up to date but I encountered two errors. Problems started when I upgraded microsoft.aspnetcore.mvc.razor.runtimecompilation 5.0.3 TO 6.0.0-preview.1.21103.6. When I downgrade back both issues disappear.

If you would like to see project's code I can try to upload some sources.

For every Blazor page:

AmbiguousMatchException: The request matched multiple endpoints. Matches: /_Host /_Host
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(CandidateState[] candidateState)
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ProcessFinalCandidates(HttpContext httpContext, CandidateState[] candidateState)
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.Select(HttpContext httpContext, CandidateState[] candidateState)
Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.SelectAsync(HttpContext httpContext, CandidateSet candidateSet)
Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

For every MVC page:

InvalidOperationException: Setting the compiled descriptor on a compiled descriptor is not allowed.
Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor.set_CompiledPageDescriptor(CompiledPageActionDescriptor value)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.CompiledPageActionDescriptorFactory.CreateCompiledDescriptor(PageActionDescriptor actionDescriptor, CompiledViewDescriptor viewDescriptor)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageLoader.LoadAsyncCore(PageActionDescriptor actionDescriptor, EndpointMetadataCollection endpointMetadata)
Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageLoaderMatcherPolicy.ApplyAsyncAwaited(CandidateSet candidates, Task<CompiledPageActionDescriptor> actionDescriptorTask, int index)
Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
pranavkm commented 3 years ago

Thanks @nono3551. We made some changes in this area so this looks like a regression. If you're able to share your code, it'd help speed up our investigations in this space.

Out of curiosity, are you using runtime compilation?

nono3551 commented 3 years ago

Thanks @nono3551. We made some changes in this area so this looks like a regression. If you're able to share your code, it'd help speed up our investigations in this space.

Out of curiosity, are you using runtime compilation?

Plan was to use it for faster development since I do not have to restart whole server. But since it is working only for MVC I am not using it very much yet.

Here is link to my repository: https://gitlab.backbone.sk/paco/paco

ghost commented 3 years ago

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

oiBio commented 3 years ago

I ran in the same issue when updating to preview 3. I used AddRazorRuntimeCompilation in my startup. Once i removed the line, it worked.

            services.AddMvcCore()
                .AddFluentValidation()
                .AddNewtonsoftJson()
                .AddRazorRuntimeCompilation()   // this is fine
                .AddXmlSerializerFormatters();

            services.AddRazorPages();
              //  .AddRazorRuntimeCompilation();    // with this line, i get "Setting the compiled descriptor on a compiled descriptor is not allowed."
maliming commented 3 years ago

Related issue: https://github.com/dotnet/aspnetcore/issues/35060

pranavkm commented 3 years ago

This was resolved as part of https://github.com/dotnet/aspnetcore/issues/35060