File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
E2ETest/ServerRenderingTests
testassets/Components.TestServer/RazorComponents/Pages Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 11// Licensed to the .NET Foundation under one or more agreements.
22// The .NET Foundation licenses this file to you under the MIT license.
33
4+ using System . Net . Http ;
45using Components . TestServer . RazorComponents ;
56using Microsoft . AspNetCore . Components . E2ETest . Infrastructure ;
67using Microsoft . AspNetCore . Components . E2ETest . Infrastructure . ServerFixtures ;
@@ -25,6 +26,21 @@ public NoInteractivityTest(
2526 public override Task InitializeAsync ( )
2627 => InitializeAsync ( BrowserFixture . StreamingContext ) ;
2728
29+ [ Fact ]
30+ public async Task CanRenderNotFound ( )
31+ {
32+ var url = $ "{ ServerPathBase } /render-not-found-ssr";
33+ Navigate ( url ) ;
34+ var statusCode = await GetStatusCodeAsync ( url ) ;
35+ Assert . Equal ( 404 , statusCode ) ;
36+ }
37+ private async Task < int > GetStatusCodeAsync ( string relativeUrl )
38+ {
39+ using var client = new HttpClient ( ) ;
40+ string absoluteUrl = $ "{ _serverFixture . RootUri } /{ relativeUrl } ";
41+ var response = await client . GetAsync ( absoluteUrl ) ;
42+ return ( int ) response . StatusCode ;
43+ }
2844 [ Fact ]
2945 public void NavigationManagerCanRefreshSSRPageWhenInteractivityNotPresent ( )
3046 {
Original file line number Diff line number Diff line change 1+ @page " /render-not-found-ssr"
2+ @inject NavigationManager NavigationManager
3+
4+ <p id =" test-info" >Any content</p >
5+
6+ @code {
7+ protected override void OnInitialized ()
8+ {
9+ NavigationManager .NotFound ();
10+ }
11+ }
Original file line number Diff line number Diff line change 2323 <li >
2424 <a href =" routing/complex-segment(value)" >Complex segments</a >
2525 </li >
26+ <li >
27+ <a href =" routing/not-found-ssr" >Not found page for Static Server Rendering</a >
28+ </li >
29+ <li >
30+ <a href =" routing/not-found-webassembly" >Not found page for Interactive WebAssembly rendering</a >
31+ </li >
32+ <li >
33+ <a href =" routing/not-found-server" >Not found page for Interactive Server rendering</a >
34+ </li >
2635</ul >
You can’t perform that action at this time.
0 commit comments