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

查看:31
本文介绍了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{...} 部分包含以下属性:

and the @functions{...} section contains the following properties:

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

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

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

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

我怎样才能做到这一点?

How can I achieve this?

推荐答案

你可以试试吗?

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天全站免登陆