I'm working on a project in .NET8 and Blazor web. I created a razor page to show list of Entities and I have two buttons one to navigate me to Edit Entity page and Passing ID of the Entity. and the second button is to navigate me to Add new Entity page.
Pages are created, no errors show, but the navigation between them is not working.Navigation Manager is injected in _Imports.razor.
Note: the page are all inside a folder name as Entities.I tried with folder name and with out, with Void and with Async Task methods, with name of pages using - and with _, all not working.
@page "/Entities"<h3>Entities</h3>@if (entities == null){<p>Loading...</p>} else{<table class="table"><thead><tr><th>ID</th><th>Name</th><th>Is Active</th><th>Actions</th></tr></thead><tbody> @foreach (var entity in entities) {<tr><td>@entity.EntityID</td><td>@entity.EntityName</td><td>@entity.IsActive</td><td><button @onclick="() => EditEntity(entity.EntityID)" class="btn btn-success">Edit</button> </td></tr> }</tbody></table>} <button @onclick="() => CreateEntity()">New Entity page</button>@code { List<Entity> entities; // Entity editingEntity; private string message = string.Empty; protected override async Task OnInitializedAsync() { // Load entities from the repository entities = (await EntityRepository.GetAllEntitiesAsync()).ToList(); } private async Task CreateEntity() { NavigationManager.NavigateTo("Entities/Add_Entity"); } private void EditEntity(int entityId) { // Navigate to the edit page with the entity ID Edit-Entity/1 NavigationManager.NavigateTo("/Edit-Entity"); }}@page "/Edit-Entity"<h3>Edit_Entity</h3>@if (entity != null){<div class="col-md-12"><div><label for="entityName">Entity Name:</label><input type="text" id="entityName" @bind="entity.EntityName" /></div><div><label for="isActive">Is Active:</label><input type="checkbox" id="isActive" @bind="entity.IsActive" /></div><!-- Add more input fields for other properties as needed --><div class="my-2"> @message</div><div class="my-2"><button type="submit" class="btn btn-primary" @onclick="SaveChanges">Save Changes</button></div></div>}else{<p>Loading...</p>}@code {}
the solve the issue of navigations between razor pages