简体   繁体   English

在服务器端 Blazor 中验证页面参数

[英]Validate page parameter in Server Side Blazor

I have a razor component page that accepts a parameter.我有一个接受参数的剃刀组件页面。

@page "/Customer/{CustomerId:int}"

Now I am checkking the method OnParametersSetAsync if the customerId exists.现在我正在检查方法 OnParametersSetAsync 如果 customerId 存在。 If it does not exists, I want to display/trigger 404 exception.如果它不存在,我想显示/触发 404 异常。

Is there any easy way to do this?有什么简单的方法可以做到这一点吗?

我认为您必须创建自己的 404 页面并使用NavigationManager将用户重定向到它

NavigationManager.NavigateTo("/404");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM