Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Unable to cast object of type 'System.String' to type 'System.Int32'. on Blazor/Razor routing parameters

$
0
0

I have tried to call a page with /somepage/{Id} where Id is a [Parameter] with a int property and the route is called as a string, it shouldn't be impicitly converting string to int? why it it wouldnt work at all? I am expecting it would recognize the parameter as it is...

what should I try to have the routing middleware to recognize the parameter ? even in MVC this works just fine...

the page routing

@page "/EditEmployee/{Id}"

the link

<a href="/EditEmployee/@Employee.EmployeeId" class="btn btn-primary m-1">Edit</a>

the parameter in the page

    [Parameter]    public int Id { get; set; }

the result is an exception and the page doesnt load


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>