0
votes

I'm having problems while debugging a blazor web assembly project.

Setup:

  • WASM Blazor UI project
  • Web API project which reference the WASM Project
  • They both share the same port.
  • I Only launch the Web API project and also get access to the blazor site. (which is odd to me)

I have those 2 line in my Web Api Project.

app.UseWebAssemblyDebugging();

app.UseEndpoints(endpoints =>
        {
            endpoints.MapRazorPages();
            endpoints.MapControllers();
            endpoints.MapFallbackToFile("index.html");
        });

Launch Settings Web API:

 "API": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "launchUrl": "",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }

Launch Settings Blazor WASM:

 "Lab.Web": {
      "commandName": "Project",
      "dotnetRunMessages": "true",
      "launchBrowser": true,
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
      "applicationUrl": "https://localhost:5001;http://localhost:5000",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }

When I try to put a breakpoint somewhere in my Blazor project. I get this message:

"The breakpoint will not currently be hit. No symbols have been loaded for this document."

I don't get this message if I run the Blazor project alone but then I don't have access to my Web API.

What is the correct way to share same port for Web API and Blazor WASM while being able to debug the WASM project??

ps: If this helps I'm using VS Studio 16.9.3.

Many thanks for your help!

1

1 Answers

1
votes

I'm assuming:

  1. You're running the project in AspNetCore and not IIS.
  2. You have the API Server project as your startup project.
  3. You are in Debug mode.
  4. Your setup is like the Web Assembly hosted on ASPNetCore template.

The only place you need inspectUri is in LaunchSettings.json is in the API project, which is where you don't have it.

When starting up in debug mode it can be slooooooow to get going, so give it time.