Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor .NET 8 - Staging launch profile not starting website VS2022

I have a Blazor .NET 8 application and I am trying to have it run in Staging in VS2022 in order to apply config transforms:

enter image description here

Setting launch profile as follows:

launch profile https

launch profile IIS

When I run my application I can see it is now hitting the breakpoint in Program.cs as expected:

Program.cs

Beyond this a browser window opens which is stuck on about:blank for a minute or so, then I eventually get this error back:

enter image description here

I have tested VS2022 with Blazor .NET 7 and MVC .NET 8 and launch profiles work as expected with no error, so this issue is specific to Blazor .NET 8. I tried creating a fresh Blazor .NET 8 app to see if it was the .sln I am working on is the issue, but it is also apparent with a new project.

Also worth mentioning I had one of my colleagues follow these steps and he was able to recreate the issue.

Has anybody come across this before and is it a bug that needs raising with Microsoft VS2022?

Thanks in advance

Rob

like image 325
Rob C Avatar asked Oct 24 '25 15:10

Rob C


1 Answers

Not a Blazor expert but the culprit seems to be the debugging. Since you run app in staging environment the app.UseWebAssemblyDebugging() is not called which seems to break VS when you are running in the debug. As workaround you can:

  • Run without debugging (Ctrl+F5 for example)

  • Add conditional call for non-development environments for debug build. For example:

    if (app.Environment.IsDevelopment())
    {
        // ...
    }
    else
    {
    #if DEBUG
        app.UseWebAssemblyDebugging();
    #endif
        // ...
    }
    

Also check the ASP.NET Core upgrade guide, was not able to find something there but maybe you will.

like image 136
Guru Stron Avatar answered Oct 26 '25 05:10

Guru Stron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!