Skip to content

Commit d3ce404

Browse files
authored
[Blazor] Fix null reference exception caused by ambiguous routes (#39833)
When two Blazor routes are ambiguous the generated exception is obfuscated by following attempts to access the route table. The reason this happens is that we update the route key before we compute a new table, and when the table fails, the next time we try the key, we return null. The solution is to wait to set the key until we've successfully computed the route table to avoid hiding exceptions in that case.
1 parent 150599c commit d3ce404

File tree

1 file changed

+1
-1
lines changed
  • src/Components/Components/src/Routing

1 file changed

+1
-1
lines changed

src/Components/Components/src/Routing/Router.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,8 @@ private void RefreshRouteTable()
159159

160160
if (!routeKey.Equals(_routeTableLastBuiltForRouteKey))
161161
{
162-
_routeTableLastBuiltForRouteKey = routeKey;
163162
Routes = RouteTableFactory.Create(routeKey);
163+
_routeTableLastBuiltForRouteKey = routeKey;
164164
}
165165
}
166166

0 commit comments

Comments
 (0)