Each time I click submit order, I get the error "An unhandled exception has occurred. See browser dev tools for details. Reload"

Kevin Ear 20 Reputation points
2024-09-11T02:55:30.19+00:00

I am following this Microsoft Learn doc to build a pizza shop and started noticing this error after following this doc https://learn.microsoft.com/en-us/training/modules/blazor-build-rich-interactive-components/3-exercise-use-javascript-libraries-blazor-apps

When I open up dev tools, I see the error "Unchecked runtime.lastError: The page keeping the extension port is moved into back/forward cache, so the message channel is closed."

  • To try and debug this, I cleared the entire cache.blazor error

What am I doing wrong? I followed the doc code by code.

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,596 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 5,906 Reputation points Microsoft Vendor
    2024-09-13T06:41:50.8233333+00:00

    Hi @Kevin Ear,

    The problem happens after clicking the submit button, so we can set the breakpoint on this line.

    var response = await HttpClient.PostAsJsonAsync(NavigationManager.BaseUri + "orders", OrderState.Order);
    

    And we can clearly see the 500 error, then we can find the post orders method and add try...catch to check the details.

    try
    {
        await _db.SaveChangesAsync();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.Message);
        throw;
    }
    

    For this issue, finally I found that the Address table is missing MobileNumber, State Columns in database.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Jason


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.