'Why does my razor page not refresh after posting

here is the code launched when updating the database from my razor page (when I move a card from the syncfusion Kanban tool) :

 [Route("api/Kanbans/Update")]
    [HttpPost]
    public List<Kanban> UpdateCard([FromBody] CRUDModel<Kanban> value)
    {
        Kanban Kanbanvalue = value.Value;
        IQueryable<Kanban> filterData = _context.Kanbans.Include(c => c.IdAssigneeKanbanNavigation).Where(c => c.IdKanban == Convert.ToInt32(Kanbanvalue.IdKanban));
        if (filterData.Any())
        {
            Kanban card = _context.Kanbans.Single(A => A.IdKanban == Convert.ToUInt32(Kanbanvalue.IdKanban));
            card.TitleKanban = Kanbanvalue.TitleKanban;
            card.TaskKanban = Kanbanvalue.TaskKanban;
            card.StatusKanban = Kanbanvalue.StatusKanban;
            card.IdAssigneeKanban = Kanbanvalue.IdAssigneeKanban;
        }
        _context.SaveChanges();
        return _context.Kanbans.ToList();
    }

With that code, the database is updated well but the razor page doesn't refresh on its own. I have to press the F5 key to perform the refresh.

Here is the code launched when F5 is pressed (and works well) :

[Route("api/[controller]")]
    [HttpPost]
    public List<Kanban> LoadCard()
    {
        return _context.Kanbans
         .Include(c => c.IdAssigneeKanbanNavigation)
         .ToList();
    }

And also, after update (before I refresh with F5) :

  • In my razor page, the mouse pointer takes the turning round shape (waiting) endlessly.
  • In the dev tool console of my browser I have this error :

Uncaught (in promise) Error: System.NullReferenceException: Object reference not set to an instance of an object. at Syncfusion.Blazor.Kanban.Internal.CrudAction1.<CrudOperation>d__2[[ligprod.Server.Models.Kanban, ligprod.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() at Syncfusion.Blazor.Kanban.SfKanban1.d__336[[ligprod.Server.Models.Kanban, ligprod.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].MoveNext() endInvokeDotNetFromJS https://localhost:5001/_framework/blazor.webassembly.js:1 Rt https://localhost:5001/_framework/blazor.webassembly.js:1 St https://localhost:5001/_framework/blazor.webassembly.js:1 _mono_wasm_invoke_js_blazor https://localhost:5001/_framework/dotnet.6.0.3.lw3578l2th.js:1 _mono_background_exec https://localhost:5001/_framework/dotnet.6.0.3.lw3578l2th.js:1 pump_message https://localhost:5001/_framework/dotnet.6.0.3.lw3578l2th.js:1

Am I writting something wrong or forgetting something in my code (blazor webassembly aspnet hosted, .net 6) ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source