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: docs/03-show-order-status.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,26 @@ Now when you run the app, you'll be able to visit this page:
56
56
57
57
Also notice that this time, no full-page load occurs when you navigate, because the URL is matched entirely within the client-side SPA. As such, navigation is instantaneous.
58
58
59
+
## Adding a page title
60
+
61
+
In your browser, the title of the new page is listed as **Blazing Pizza** and it would be nice to update the title to reflect that this is the 'My Orders' page. We can use the new `PageTitle` component to update the title from the `MyOrders.razor` page:
62
+
63
+
```html
64
+
@page "/myorders"
65
+
66
+
<PageTitle>Blazing Pizza - My Orders</PageTitle>
67
+
68
+
<divclass="main">
69
+
My orders will go here
70
+
</div>
71
+
```
72
+
73
+
This works because inside the `Program.cs` file is an entry that adds a `HeadOutlet` component to the HTML presenting the BlazingPizza application. Blazor uses this `HeadOutlet` to write content into the header of the HTML page.
Look closely at the top bar. Notice that when you're on "My orders", the link *isn't* highlighted in yellow. How can we highlight links when the user is on them? By using a `NavLink` component instead of a plain `<a>` tag. The only special thing a `NavLink` component does is toggle its own `active` CSS class depending on whether its `href` matches the current navigation state.
Copy file name to clipboardExpand all lines: docs/05-checkout-with-validation.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,6 +9,8 @@ It's time to fix this by adding a "checkout" screen that requires customers to e
9
9
Start by adding a new page component, `Checkout.razor`, with a `@page` directive matching the URL `/checkout`. For the initial markup, let's display the details of the order using your `OrderReview` component:
### Optional: Optimize JSON interactions with .NET 6 JSON CodeGeneration
267
+
268
+
Starting with .NET 6, the System.Text.Json.JsonSerializer supports working with optimized code generated for serializing and deserializing JSON payloads. Code is generated at build time, resulting in a significant performance improvement for the serialization and deserialization of JSON data. This is configured by taking the following steps:
269
+
270
+
1. Create a partial Context class that inherits from `System.Text.Json.Serialization.JsonSerializerContext`
271
+
2. Decorate the class with the `System.Text.Json.JsonSourceGenerationOptions` attribute
272
+
3. Add `JsonSerializable` attributes to the class definition for each type that you would like to have code generated
273
+
274
+
We have already written this context for you and it is located in the `BlazingPizza.Shared.Order.cs" file
You can now optimize the calls to the HttpClient in the `OrdersClient` class by passing an `OrderContext.Default` parameter pointing to the type sought as the second parameter. Updating the methods in the `OrdersClient` class should look like the following:
Update each page where an `HttpClient` is used to manage orders to use the new typed `OrdersClient`. Inject an `OrdersClient` instead of an `HttpClient` and use the new client to make the API call. Wrap each call in a `try-catch` that handles exceptions of type `AccessTokenNotAvailableException` by calling the provided `Redirect()` method.
0 commit comments