@page "/servers/{id:int}" @* Route constraints: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-9.0#route-constraints *@ @* Note that this attribute now needs to be removed, because Routing is globally interactive. The navigation manager only will respond correctly if all its behaviours are the same. *@ @* @attribute [ExcludeFromInteractiveRouting] *@ @inject NavigationManager NavigationManager @inject IJSRuntime JSRuntime

Edit server



@if (server != null) {
  Close
} @code { [Parameter] // This is a root parameter. public int Id { get; set; } [SupplyParameterFromForm(FormName = "formServer")] private Server? server { get; set; } protected override void OnParametersSet() { server ??= ServersRepository.GetServerById(this.Id); } private void SubmitServer() { if (server != null) { ServersRepository.UpdateServer(server.Id, server); } // An exception is raised when debugging from VS Code, but not when using dotnet watch. NavigationManager.NavigateTo($"/servers/back_from/{this.server?.City}"); } private async Task OnBeforeInternalNavigation(LocationChangingContext context) { var isConfirmed = await JSRuntime.InvokeAsync("confirm", "Are you sure you want to leave this page?"); if (!isConfirmed) { context.PreventNavigation(); } } }