Search code examples
blazorblazor-webassemblyblazor-hosted

In the Blazor WASM server start up project shows page not found error


While creating the Blazor WASM application, why startup project is set to Server by default. How does the view on the client-side is called and displayed?

When I ran the client project as a startup, the view is displayed in the browser but can't able to access the controller.


Solution

  • If you have checked the "ASP.NET Core Hosted" flag during project creation the Client project is hosted togheter with your server project.

    Opening the site from the home page the routing redirect to index.html fille that is published in the wwwroot folder.

    The Client is configured out of the box to call the API endpoints (your controllers) using its base address.
    If the Client start from the same hostname and port of the server the HttpClient works as expected.

    But if you try to start an ASP.NET Hosted app starting the Client project, without change this configuration and without start in parallel the Server project, it cannot reach the backend.