Blazor Server render-mode change causing Exception even when changed back to original mode

Posted 315 days ago by JustSomeGuy
0

(First post, let me know if this should be posted elsewhere!)

I'm building a Blazor Server application and wanted to test the response rates (locally through VS2022 Debugger) between the different render-mode options.

 

However, after going into the _Host.cshtml file and setting render-mode to Server (from ServerPrerendered), the web app suddenly threw an exception. Changing it back to ServerPrerendered threw the same error, and I'm no longer able to run the application at all (debugger, local, or hosted through IIS). 

 

Stack Trace below:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')



System.Collections.Generic.List<T>.get_Item(int index)

BurningWebPlatform.Pages.TurnReport.<BuildRenderTree>b__0_1(RenderTreeBuilder __builder2)

Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder.AddContent(int sequence, RenderFragment fragment)

Radzen.Blazor.RadzenStack.BuildRenderTree(RenderTreeBuilder __builder)

Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, out Exception renderFragmentException)

Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()

Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(int componentId, RenderFragment renderFragment)

Microsoft.AspNetCore.Components.ComponentBase.StateHasChanged()

Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()

Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()

Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters)

Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(int componentId, ParameterView initialParameters)

Microsoft.AspNetCore.Components.Rendering.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters)

Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext+<>c__11<TResult>+<<InvokeAsync>b__11_0>d.MoveNext()

Microsoft.AspNetCore.Mvc.ViewFeatures.StaticComponentRenderer.PrerenderComponentAsync(ParameterView parameters, HttpContext httpContext, Type componentType)

System.Threading.Tasks.ValueTask<TResult>.get_Result()

Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.PrerenderedServerComponentAsync(HttpContext context, ServerComponentInvocationSequence invocationId, Type type, ParameterView parametersCollection)

Microsoft.AspNetCore.Mvc.ViewFeatures.ComponentRenderer.RenderComponentAsync(ViewContext viewContext, Type componentType, RenderMode renderMode, object parameters)

System.Threading.Tasks.ValueTask<TResult>.get_Result()

Microsoft.AspNetCore.Mvc.TagHelpers.ComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output)

Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.<RunAsync>g__Awaited|0_0(Task task, TagHelperExecutionContext executionContext, int i, int count)

BurningWebPlatform.Pages.Pages__Host.<ExecuteAsync>b__14_1() in _Host.cshtml

23.         <component type="typeof(App)" render-mode="ServerPrerendered" />

at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext.SetOutputContentAsync()
         at BurningWebPlatform.Pages.Pages__Host.ExecuteAsync()
         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.<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()

So, it gives me the line number (23) in _Host.cshtml, right where my main App content in the <body> is being rendered

20 <component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
21 </head>
22 <body>
23  <component type="typeof(App)" render-mode="ServerPrerendered" />

 

 but does not indicate how this becomes an Index issue (5 options for this setting, we're giving it index 3 behind the Enum). I'm wondering if there is anything in the background that also got changed after I changed this setting in _Host.cshtml, and is not changing after going back to ServerPrerendered? Is there anything you guys know about this type of issue? Please let me know, thanks guys!

Someone is typing...

Post a Reply

You must be logged in to add a new post.
Number of online users: 0
An error has occurred. This application may no longer respond until reloaded. Reload 🗙