将路由参数添加到Blazor Server App&#x27的索引页面

发布于 2025-01-29 00:53:59 字数 475 浏览 1 评论 0原文

我正在使用.NET 6.0开发Blazor Server应用程序。我想让索引页面使用路由参数:

@page "/{vendorId}"

@functions {
    [Parameter]
    public string? vendorId { get; set; }
}

因此,将导航到https:// localhost:7071/Chesters的用户将检索Chesters的数据,而用户则导航到https:// localhost:7071/smokeyjoe/smokeyjoe Will Will Will Will Will要检索Smokeyjoe的数据。问题是用户首先导航到该URL时,他必须先登录以进行身份​​验证。一旦他进行身份验证,该页面就会重定向回到https:// localhost:7071我丢失了路由参数。如果经过身份验证的用户将导航到其预​​期的URL,则一切都按预期工作。那么,如何防止身份验证过程将初始导航删除到首选URL?

I'm developing a Blazor Server app using .NET 6.0. I would like for the index page to utilize a route parameter:

@page "/{vendorId}"

@functions {
    [Parameter]
    public string? vendorId { get; set; }
}

So, a user navigating to https://localhost:7071/Chesters will be retrieving data for Chesters, while a user navigating to https://localhost:7071/SmokeyJoe will be retrieving data for SmokeyJoe. The problem is when the user first navigates to that URL, he must first login to be authenticated. Once he's authenticated, the page is redirected back to https://localhost:7071 where I lose the route parameter. If the authenticated user then navigates to his intended URL, everything works as expected. So, how do I keep the authentication process from wiping out the initial navigation to the preferred URL?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文