Reputation: 1839
I have a Blazor WASM app (.NET 6). I use SWA CLI to emulate the Azure Static Web App env locally. I can debug Blazor WASM when I run it alone, but I need SWA CLI because there are auth features there. Is it possible to debug it?
I try to run something like
swa start http://localhost:5001 --api-location http://localhost:7071
I run my Azure Functions on the other process, and I start a debugging Visual Studio 2022 session. But breakpoints are not hit in Visual Studio.
Another try:
swa start http://localhost:5001 --run "dotnet watch run" --api-location http://localhost:7071
This time I let SWA CLI run the Blazor app. Then I use "Attach to a process" feature of Visual Studio 2022. To no avail, too.
So... How do I debug a Blazor WASM app behind SWA CLI proxy? Many thanks.
Upvotes: 3
Views: 671
Reputation: 21
When you run the Client app from Visual Studio, it starts it in a brand new browser window. After you start your swa-cli proxy, make sure that you enter the URL provided by the swa-cli into that brand new browser window.
For general ASP.NET Core apps, you can disable this behavior and let yourself to use whichever browser window you want. For some reason, you cannot do that with Blazor WASM.
Upvotes: 0
Reputation: 41
I had the exact same problem.
Searching for an answer, I came across the following article which explains into great detail how to solve our problem 😀
You have to start the swa cli as you mentioned, pointing to the localhost urls. But then what links it all thoghether is adding the launchUrl setting to the client launchSettings.json file. That setting should be the url of the swa cli host, by default "http://localhost:4280". After setting that, it all started working for me.
Hope it helps..
Upvotes: 2