I created ASP.NET MVC online store application.
It has MVC component shopping cart summary (it is located on right top of the page).
It just show number of products and total sum:
The cart summary is included on _Layout.cshtml page: `<vc:cart-summary />
Then I added Blazor server-side component which shows cart items as table (so user can review items and change quantity):
The Blazor shopping cart table works fine – data are shown and I can change quantity (totals are refreshed). Every time quantity changed I want to refresh cart summary component (in top right) to show fresh data so I call UpdateCartSummary which calls JS function:
The summary component is got correctly (generated view) but quantity and sum are not updated. If I hit refresh in a browser (F5) nothing changed. Second hit of F5 causes the summary cart to be correct (quantity and sum).
The Cart class uses Session:
So need to refresh page twice to get fresh (correct) cart summary data.
The question – what happening and how to solve the problem? How can I get correct cart summary component data in UpdateCartSummary method in my Blazor component?
Thanks.
I tried to call UpdateCartSummary several times – didn’t help.