Enhanced Form Navigation
In .NET 8, we got server-side rendering. Adding interactivity to a component is simple, as we have seen. But sometimes we just want a form and a submit button. Do we really have to enable WebAssembly or a SignalR connection for this? I’m glad you asked! The answer is, no, we don’t.
Let’s add a component to showcase that our blog posts need comments:
- In the
SharedComponents
project, in thePages
folder, add a new Razor component calledComments.razor
. This component should do two things: list comments and create a new comment. - In the
comments
file, replace the content with the following:@using SharedComponents.ReusableComponents @using Microsoft.AspNetCore.Components.Forms @inject IBlogApi _api <h3>Comments</h3> @foreach (var c in comments) { <div class="media mb-4"> <div class="media-body"> <h5 class="mt-0">@c.Name</h5>...