question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

debugging blazor application in non-development mode does not work

See original GitHub issue

Describe the bug

When I debug my application with Development environment variable set - everything works. When I remove the variable or rename it to Production, then website becomes unreachable.

To Reproduce

  1. create a new Blazor WASM application with asp.net core hosting option selected
  2. change the startup mode from IIS Express to Kestrel

image

  1. start debug session.

Expected, actual: browser window launched, website is reachable/loaded.

  1. go to launch settings and remove the Development value or set it to Production for ASPNETCORE_ENVIRONMENT env variable setting

image

  1. start debug session.

Expected

browser window launched, website is reachable/loaded.

Actual

image

  • browser window opened but the default webpage is not opened

  • if you manually navigate to either of the pages, i.e. http://localhost:5000, you will see the This localhost page can’t be found (404) error

image

  • if you wait exactly 1 minute with debug session running and staring at window you will see the exception in VisualStudio - failed to launch debug adapter:

image

Exceptions (if any)

  1. This localhost page can’t be found
  2. failed to launch debug adapter

Further technical details

Microsoft Visual Studio Community 2019
Version 16.8.6
VisualStudio.16.Release/16.8.6+31019.35
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Community

Visual C++ 2019   00435-60000-00000-AA596
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019   16.8.560.26713
ASP.NET and Web Tools 2019

ASP.NET Core Razor Language Services   16.1.0.2052803+84e121f1403378489b842e1797df2f3f5a49ac3c
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2019   16.8.560.26713
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   16.8.560.26713
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools   16.8.560.26713
Azure Functions and Web Jobs Tools

C# Tools   3.8.0-5.20604.10+9ed4b774d20940880de8df1ca8b07508aa01c8cd
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Edit Project   1.6.34
An open source Visual Studio extension to add the context menu for editing project/solution file.

GitExtensions   1.0
Git Extensions is a graphical user interface for Git that allows you to control Git without using the command-line

IntelliCode Extension   1.0
IntelliCode Visual Studio Extension Detailed Info

Markdown Editor   1.12.253
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30924.1

Microsoft Continuous Delivery Tools for Visual Studio   0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   2.1.113+g422d40002e.RR
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards   1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

NuGet Package Manager   5.8.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
.NET SDK (reflecting any global.json):
 Version:   5.0.103
 Commit:    72dec52dbd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19042
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.103\

Host (useful for support):
  Version: 5.0.3
  Commit:  c636bbdc8a

.NET SDKs installed:
  5.0.103 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

additional options tried

I tried changing

"applicationUrl": "https://localhost:5001;http://localhost:5000", to

"applicationUrl": "http://localhost:5000",

commenting out HTTPS redirect: //app.UseHttpsRedirection(); in Startup.cs removing non-development specific configuration:

            //if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseWebAssemblyDebugging();
            }
            /*else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            //app.UseHttpsRedirection();*/

Neither of my attempts helped… I am still not able to debug the application no matter what I do… Am I doing something wrong?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
xendrencommented, Mar 9, 2022

Is there any way to escalate this or at least confirm if it only relates to debugging? I’m trying to evaluate whether our company should use Blazor, Mudblazor, or choose something else. Unfortunately, I have just encountered this bug with the stock Mudblazor and Blazor project templates from “dotnet new”. All you have to do to make it fail is to change the “ASPNETCORE_ENVIRONMENT” variable to something other than “Development”. With MudBlazor, you get a stack trace and the index page only partially renders with the mudblazor icon enormous. With the template Blazor app, there are no exceptions raised, but the stock side panel fails to render.

I tried removing the isDevelopment() logic completely in Program.cs, but I get the same behavior. Somewhere in the bowls of the code, something is expecting that environment variable to equal Development, or it misfires.
I’m using the latest .Net 6 SDK.

Can someone please at least confirm this is ONLY an issue with debugging with Blazor before we start developing? I don’t want to choose Blazor and end up wasting our time later if we have to bypass the builtin .Net settings functionality to get it to work.

0reactions
msftbot[bot]commented, Jul 27, 2021

We’ve moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot debug Blazor wasm
I managed to get it working with Microsoft's Edge browser. Although I'm using VSCode on linux, it should be similar for Visual Studio...
Read more >
Debug ASP.NET Core Blazor WebAssembly
Learn how to debug Blazor WebAssembly with browser developer tools and an integrated development environment (IDE).
Read more >
Why is it IMPOSSIBLE to debug Blazor
I sometimes have to set the breakpoints after I have started the debug for them to be hit properly. Also, some breakpoints can...
Read more >
Untitled
Debugger agent is not enabled blazor No longer able to debug Blazor WebAssembly application after Azure Application Insights Snapshot Debugger for .
Read more >
Coding Apps in Blazor from a non-developer standpoint - Part 2
Quit Debugging-mode by pressing Shift-F5, or by clicking the Stop button (red square button in the top menu) in Visual Studio, or by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found