Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
In .NET 8 preview 5, when creating a SSR Blazor app and using route parameters with e.g. int type, the page fails to load with an error: InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Int32'.
Here is the component I used to test this:
@page "/counter/{currentCount:int?}"
<p role="status">Current count: @CurrentCount</p>
@code {
[Parameter] public int CurrentCount { get; set; }
}
I tried this on .NET 7 Blazor WASM app and it worked.
Expected Behavior
When going to an url https://localhost:7208/counter/5 the CurrentCount property should be set to 5.
Steps To Reproduce
Create a .NET 8 Blazor SSR app, copy the code to a Counter.razor component and navigate to it's url.
.NET Version
8.0.100-preview.5.23303.2