Blazor路由中的多个查询字符串参数 [英] Multiple query string parameters in Blazor routing

查看:832
本文介绍了Blazor路由中的多个查询字符串参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的项目中有多个工作示例,这些示例从url检索1个查询参数,但是当尝试对多个url参数遵循相同的约定时,我在chrome调试器控制台中收到以下错误:

I have multiple working examples in my current project of retrieving 1 query parameter from the url however when trying to follow the same convention for multiple url params, I'm receiving the following error in the chrome debugger console:

Error: System.InvalidOperationException: 'Router' cannot find any component with a route for '/confirmemail'.

我的页面路线定义为:

@page "/confirmemail/{Token}/{UserId}"

@functions {...} 部分包含以下属性:

[Parameter]
string Token { get; set; }
[Parameter]
string UserId { get; set; }

我正在尝试检索如下所示网址的查询字符串参数:

I am trying to retrieve the query string parameters for a url that looks like this:

http:// localhost:50466 / confirmemail?Token = SomeReallyLargeToken& UserId = SomeGuidUserId

如何实现?

推荐答案

您可以尝试吗?

http://localhost:50466/confirmemail/SomeReallyLargeToken/SomeGuidUserId

我认为应该可以。

更新:如果您想从查询参数中精确获取值,请参见以下示例: https://learn-blazor.com/pages/router/

UPDATE: If you want to get values exactly from query parameters good example is here https://learn-blazor.com/pages/router/

这篇关于Blazor路由中的多个查询字符串参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆