【发布时间】:2020-12-24 12:26:06
【问题描述】:
想象一下,这是通往我的 Blazor 页面的路径:@page "/a/b/c/{numericvalue:int}"
以下请求将匹配:
/a/b/c/1
/a/b/c/2
/a/b/c/509
这个请求...
/a/b/c/test
... 将显示 App.razor 文件中定义的 NotFound 页面:
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
但现在我也想拒绝奇数。发现号码为奇数后,如何手动显示 NotFound 页面?我的代码如下所示:
@code{
[Parameter]
public int NumericValue {
set => {
if(value % 2 == 1)
// show the 404 page
}
}
}
【问题讨论】:
标签: razor razor-pages blazor-webassembly