-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add NotFoundPage
to Router
#60970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add NotFoundPage
to Router
#60970
Changes from 5 commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
11956ec
Add `NotFoundPage`.
ilonatommy 216ec31
Fix rebase error.
ilonatommy 3168993
Draft of template changes.
ilonatommy 067cfd2
Typo errors.
ilonatommy 6d22aad
NavigationManager is not needed for SSR.
ilonatommy 6ea7082
Add BOM to new teamplate files.
ilonatommy 25e8e66
Move instead of exclude.
ilonatommy 1060b4d
Clean up, fix tests.
ilonatommy fc696c3
Fix
ilonatommy 44e7d8e
Apply smallest possible changes to templates.
ilonatommy ae68011
Missing changes to baseline.
ilonatommy 39deb2b
Prevent throwing.
ilonatommy 6b620d5
Fix configurations without global router.
ilonatommy 6876252
Merge branch 'main' into fix-58815
ilonatommy 74e3eae
Fix "response started" scenarios.
ilonatommy e10b90c
Fix template tests.
ilonatommy b660d19
Fix baseline tests.
ilonatommy d566c4b
This is a draft of uneffective `UseStatusCodePagesWithReExecute`, cc …
ilonatommy d41bd5b
Update.
ilonatommy 005f217
Fix reexecution mechanism.
ilonatommy 8c7b6d2
Fix public API.
ilonatommy f876e4d
Args order.
ilonatommy 8744e8b
Draft of test.
ilonatommy aee53a9
Per page interactivity test.
ilonatommy de91b4b
Revert unnecessary change.
ilonatommy 7e7f1fe
Typo: we want to stop only if status pages are on.
ilonatommy 6a10062
Remove comments.
ilonatommy 5518812
Fix tests.
ilonatommy c8eb629
Feedback.
ilonatommy 66b563c
Feedback.
ilonatommy 1da92f9
Failing test - re-executed without a reason.
ilonatommy b7775ef
Add streaming test after response started.
ilonatommy cb32f94
Test SSR with no interactivity.
ilonatommy 8273758
Stop the renderer regardless of `Response.HasStarted`.
ilonatommy c31812c
Feedback: not checking status code works as well.
ilonatommy b162946
Feedback: improve handling streaming-in-process case.
ilonatommy f57b0b7
Merge branch 'main' into fix-58815
ilonatommy 3e77c62
Throw on NotFound without global router.
ilonatommy d612592
Use `IStatusCodeReExecuteFeature`.
ilonatommy cd5dffa
Unify "fallback" pages - check for titles only.
ilonatommy b416805
Fix early return condition.
ilonatommy fc63304
Merge branch 'main' into fix-58815
ilonatommy c0e7f86
Feedback.
ilonatommy 124b470
Merge branch 'main' into fix-58815
ilonatommy ebdf9a9
No-op instead of exception.
ilonatommy fc49fe6
Solve merge conflict: hard stop in redirection and deferred stop in 404.
ilonatommy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
src/Components/test/testassets/Components.WasmMinimal/Pages/CustomNotFoundPage.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@page "/render-custom-not-found-page" | ||
|
||
<h3 id="test-info">Welcome On Custom Not Found Page</h3> | ||
<p>Sorry, the page you are looking for does not exist.</p> |
24 changes: 23 additions & 1 deletion
24
src/Components/test/testassets/Components.WasmMinimal/Routes.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...jectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp.Client/Pages/WeatherDetails.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@page "/weather/details/{date}" | ||
@*#if (UseServer && !InteractiveAtRoot) | ||
@rendermode InteractiveAuto | ||
##elseif (!InteractiveAtRoot) | ||
@rendermode InteractiveWebAssembly | ||
##endif*@ | ||
@inject NavigationManager NavigationManager | ||
|
||
@if (weatherDetails == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<div> | ||
<p><strong>Date:</strong> @weatherDetails.Date.ToShortDateString()</p> | ||
<p><strong>Temperature (C):</strong> @weatherDetails.TemperatureC</p> | ||
<p><strong>Temperature (F):</strong> @weatherDetails.TemperatureF</p> | ||
<p><strong>Summary:</strong> @weatherDetails.Summary</p> | ||
</div> | ||
} | ||
|
||
@code{ | ||
[Parameter] | ||
public string? Date { get; set; } | ||
|
||
private WeatherForecast? weatherDetails; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
weatherDetails = null; | ||
|
||
// Simulate fetching data from a database | ||
await Task.Delay(500); | ||
|
||
// Simulate a scenario where the details are not found | ||
NavigationManager.NotFound(); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...tTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Models/WeatherForecast.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
public class WeatherForecast | ||
{ | ||
public int Id { get; set; } | ||
public DateOnly Date { get; set; } | ||
public int TemperatureC { get; set; } | ||
public string? Summary { get; set; } | ||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
} |
4 changes: 4 additions & 0 deletions
4
...rojectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Pages/NotFound.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@page "/not-found" | ||
|
||
<h3>Not Found</h3> | ||
<p>Sorry, the content you are looking for does not exist.</p> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...Templates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Pages/WeatherDetails.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
@page "/weather/details/{id:int}" | ||
@*#if (!InteractiveAtRoot) --> | ||
@attribute [StreamRendering] | ||
##endif*@ | ||
@inject NavigationManager NavigationManager | ||
|
||
@if (weatherDetails == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<div> | ||
<p><strong>Date:</strong> @weatherDetails.Date.ToShortDateString()</p> | ||
<p><strong>Temperature (C):</strong> @weatherDetails.TemperatureC</p> | ||
<p><strong>Temperature (F):</strong> @weatherDetails.TemperatureF</p> | ||
<p><strong>Summary:</strong> @weatherDetails.Summary</p> | ||
</div> | ||
} | ||
|
||
@code{ | ||
[Parameter] | ||
public int Id { get; set; } | ||
|
||
private WeatherForecast? weatherDetails; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
weatherDetails = null; | ||
|
||
// Simulate fetching data from a database | ||
await Task.Delay(500); | ||
ilonatommy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
// Simulate a scenario where the details are not found | ||
NavigationManager.NotFound(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@ECHO OFF | ||
ilonatommy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
SETLOCAL | ||
|
||
:: This command launches a Visual Studio solution with environment variables required to use a local version of the .NET Core SDK. | ||
|
||
:: This tells .NET Core to use the same dotnet.exe that build scripts use | ||
SET DOTNET_ROOT=%~dp0\.dotnet | ||
SET DOTNET_ROOT(x86)=%~dp0\.dotnet\x86 | ||
|
||
:: This tells .NET Core not to go looking for .NET Core in other places | ||
SET DOTNET_MULTILEVEL_LOOKUP=0 | ||
|
||
:: Put our local dotnet.exe on PATH first so Visual Studio knows which one to use | ||
SET PATH=%DOTNET_ROOT%;%PATH% | ||
|
||
SET sln=%~1 | ||
|
||
IF "%sln%"=="" ( | ||
echo Error^: Expected argument ^<SLN_FILE^> | ||
echo Usage^: startvs.cmd ^<SLN_FILE^> | ||
|
||
exit /b 1 | ||
) | ||
|
||
IF NOT EXIST "%DOTNET_ROOT%\dotnet.exe" ( | ||
echo .NET Core has not yet been installed. Run `%~dp0restore.cmd` to install tools | ||
exit /b 1 | ||
) | ||
|
||
IF "%VSINSTALLDIR%" == "" ( | ||
start "" "%sln%" | ||
) else ( | ||
"%VSINSTALLDIR%\Common7\IDE\devenv.com" "%sln%" | ||
) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.