debugging blazor application in non-development mode does not work
See original GitHub issueDescribe 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
- create a new
Blazor WASMapplication withasp.net core hostingoption selected - change the startup mode from
IIS Expressto Kestrel

- start debug session.
Expected, actual: browser window launched, website is reachable/loaded.
- go to launch settings and remove the
Developmentvalue or set it toProductionforASPNETCORE_ENVIRONMENTenv variable setting

- start debug session.
Expected
browser window launched, website is reachable/loaded.
Actual

-
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

- 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:

Exceptions (if any)
- This localhost page can’t be found
- 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:
- Created 3 years ago
- Comments:7 (4 by maintainers)

Top Related StackOverflow Question
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.
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.