问题
我正在尝试将Query Params
从剃须刀页面传递到login.cshtml页面。但是我无法收到Query Params
方法
我有剃须刀组件ForgetPassword.razor
。它具有以下功能UpdatePassword
:
private async Task UpdatePassword()
{
//The logic to be updated password will be implemented here
.
.
.
//After user password has been updated then we need to redirect to login.cshtml page with a query param. I am using NavigationManager to redirect to login.cshtml page
var query = new Dictionary<string, string> { { "message", "The password was successfully changed" } };
_navManager.NavigateTo(QueryHelpers.AddQueryString("/login", query));
}
现在,当我被定向到login.cshtml
页面时。我正在使用函数OnGet
来接收参数。当我从login.cshtml
进入ForgetPassword.razor
页面时。该函数被调用,但消息始终为null
。
public async Task<IActionResult> OnGet(string message)
{
//Some logic related to message here
}
但是,如果我在login.cshtml
页上,并在URL标签中手动输入QueryParams
,例如:
https://localhost:44372/login?message=HelloWorld
我确实收到了消息。
请帮助我解决这个问题。
致谢
Saad
答案 0 :(得分:1)
问题已解决。我将功能更改为_navManager.NavigateTo(QueryHelpers.AddQueryString("/login", query),true);
这将强制重新加载为true。
非常感谢您的帮助