You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/blazor/fundamentals/routing.md
+10-15Lines changed: 10 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -730,35 +730,30 @@ When a component is rendered statically (static SSR) and `NavigationManager.NotF
730
730
}
731
731
```
732
732
733
-
Two approaches for providing Not Found content for global interactive rendering:
733
+
To provide Not Found content for global interactive rendering, use a Not Found page (Razor component).
734
734
735
-
* Use a Not Found page (Razor component).
736
-
* Specify Not Found content in the [`Router` component's](xref:blazor/fundamentals/routing#route-templates)<xref:Microsoft.AspNetCore.Components.Routing.Router.NotFound%2A> property (`<NotFound>...</NotFound>` markup or by setting the `NotFound` parameter to a render fragment in C# code).
737
-
738
-
The following example uses a Not Found page (`NotFoundPage` component) to render Not Found content.
739
-
740
-
`NotFoundPage.razor`:
735
+
`NotFound.razor`:
741
736
742
737
```razor
743
738
<h1>Not Found</h1>
744
739
745
740
<p>Sorry! Nothing to show.</p>
746
741
```
747
742
748
-
Specify the `NotFoundPage` component to the `Router` component in `Routes.razor`. You might need to specify the component's namespace with an [`@using`](xref:mvc/views/razor#using) directive either at the top of the `Routes.razor` file or in an [`_Imports.razor` file](xref:blazor/components/index#component-name-class-name-and-namespace).
743
+
Assign the `NotFound` component to the router's `NotFoundPage` parameter. `NotFoundPage` supports routing that can be used across re-execution middleware, including non-Blazor middleware. If the `NotFound` render fragment is defined together with `NotFoundPage`, the page has higher priority.
744
+
745
+
In the following example, the preceding `NotFound` component is present in the app's `Pages` folder and passed to the `NotFoundPage` parameter:
When a component is rendered with a global interactive render mode, calling `NotFound` signals the Blazor router to render Not Found content, which is the `NotFoundPage` component:
756
+
When a component is rendered with a global interactive render mode, calling `NotFound` signals the Blazor router to render the `NotFound` component:
Copy file name to clipboardExpand all lines: aspnetcore/release-notes/aspnetcore-10/includes/blazor.md
+18-14Lines changed: 18 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -110,10 +110,6 @@ In prior Blazor releases, response streaming for <xref:System.Net.Http.HttpClien
110
110
111
111
This is a breaking change because calling <xref:System.Net.Http.HttpContent.ReadAsStreamAsync%2A?displayProperty=nameWithType> for an <xref:System.Net.Http.HttpResponseMessage.Content%2A?displayProperty=nameWithType> (`response.Content.ReadAsStreamAsync()`) returns a `BrowserHttpReadStream` and no longer a <xref:System.IO.MemoryStream>. `BrowserHttpReadStream` doesn't support synchronous operations, such as `Stream.Read(Span<Byte>)`. If your code uses synchronous operations, you can opt-out of response streaming or copy the <xref:System.IO.Stream> into a <xref:System.IO.MemoryStream> yourself.
112
112
113
-
<!-- UNCOMMENT FOR PREVIEW 5 ...
114
-
Waiting on https://github.com/dotnet/runtime/issues/97449
115
-
... and update the Call web API article Line 983
116
-
117
113
To opt-out of response streaming globally, use either of the following approaches:
118
114
119
115
* Add the `<WasmEnableStreamingResponse>` property to the project file with a value of `false`:
@@ -124,12 +120,6 @@ To opt-out of response streaming globally, use either of the following approache
124
120
125
121
* Set the `DOTNET_WASM_ENABLE_STREAMING_RESPONSE` environment variable to `false` or `0`.
126
122
127
-
............. AND REMOVE THE NEXT LINE .............
128
-
129
-
-->
130
-
131
-
To opt-out of response streaming globally, set the `DOTNET_WASM_ENABLE_STREAMING_RESPONSE` environment variable to `false` or `0`.
132
-
133
123
To opt-out of response streaming for an individual request, set <xref:Microsoft.AspNetCore.Components.WebAssembly.Http.WebAssemblyHttpRequestMessageExtensions.SetBrowserResponseStreamingEnabled%2A> to `false` on the <xref:System.Net.Http.HttpRequestMessage> (`requestMessage` in the following example):
Code that relied on <xref:Microsoft.AspNetCore.Components.NavigationException> being thrown should be updated. For example, in the default Blazor Identity UI, the `IdentityRedirectManager` previously threw an <xref:System.InvalidOperationException> after calling `RedirectTo` to ensure it wasn't invoked during interactive rendering. This exception and the [`[DoesNotReturn]` attributes](xref:System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute) should now be removed.
389
379
390
-
<!-- HOLD FOR PREVIEW 5
391
-
392
380
To revert to the previous behavior of throwing a <xref:Microsoft.AspNetCore.Components.NavigationException>, set the following <xref:System.AppContext> switch:
393
381
394
382
```csharp
@@ -397,8 +385,6 @@ AppContext.SetSwitch(
397
385
isEnabled: true);
398
386
```
399
387
400
-
-->
401
-
402
388
### Not Found responses using `NavigationManager` for static SSR and global interactive rendering
403
389
404
390
The <xref:Microsoft.AspNetCore.Components.NavigationManager> now includes a `NotFound` method to handle scenarios where a requested resource isn't found during static server-side rendering (static SSR) or global interactive rendering:
@@ -412,3 +398,21 @@ Per-page/component rendering support is planned for Preview 5 in June, 2025.
412
398
You can use the `NavigationManager.OnNotFound` event for notifications when `NotFound` is invoked.
413
399
414
400
For more information and examples, see <xref:blazor/fundamentals/routing?view=aspnetcore-10.0#not-found-responses>.
401
+
402
+
### Blazor router has a `NotFoundPage` parameter
403
+
404
+
Rendering content after triggering the `NavigationManager.NotFound` method can be now handled by passing a parameter with a component type to the router. This is now recommended over using the `NotFound` render fragment because `NotFoundPage` supports routing that can be used across re-execution middleware, including non-Blazor middleware. If the `NotFound` render fragment is defined together with `NotFoundPage`, the page has higher priority.
405
+
406
+
In the following example, a `NotFound` component is present in the app's `Pages` folder and passed to the `NotFoundPage` parameter. The `NotFound` page takes priority over the content in the `NotFound` fragment.
0 commit comments