<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blazor running &#8211; ASP.NET Hosting Reviews and Guides</title>
	<atom:link href="https://topreviewhostingasp.net/tag/blazor-running/feed/" rel="self" type="application/rss+xml" />
	<link>https://topreviewhostingasp.net</link>
	<description>Help you to find best ASP.NET Core Hosting</description>
	<lastBuildDate>Fri, 03 Mar 2023 04:54:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://topreviewhostingasp.net/wp-content/uploads/2017/01/cropped-trhaico-32x32.png</url>
	<title>blazor running &#8211; ASP.NET Hosting Reviews and Guides</title>
	<link>https://topreviewhostingasp.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How to Troubleshoot .NET Blazor WASM Debugging</title>
		<link>https://topreviewhostingasp.net/how-to-troubleshoot-net-blazor-wasm-debugging/</link>
					<comments>https://topreviewhostingasp.net/how-to-troubleshoot-net-blazor-wasm-debugging/#respond</comments>
		
		<dc:creator><![CDATA[Jacques Hunt]]></dc:creator>
		<pubDate>Fri, 03 Mar 2023 04:52:49 +0000</pubDate>
				<category><![CDATA[Hosting Tips]]></category>
		<category><![CDATA[asp net core]]></category>
		<category><![CDATA[blazor debugging]]></category>
		<category><![CDATA[blazor running]]></category>
		<category><![CDATA[blazor tips]]></category>
		<category><![CDATA[blazor tutorial]]></category>
		<guid isPermaLink="false">https://topreviewhostingasp.net/?p=3462</guid>

					<description><![CDATA[The “Obvious” of WASM Debugging While coding with Blazor WASM, it’s easy to get lulled into a false sense of comfort. After all, it’s all C# and .NET, right? Well, not exactly. It’s easy to gloss over that while our code runs on a version of .NET, it’s not the one we know and love. [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="the-obvious-of-wasm-debugging">The “Obvious” of WASM Debugging</h2>



<p>While coding with Blazor WASM, it’s easy to get lulled into a false sense of comfort. After all, it’s all C# and .NET, right? Well, not exactly. It’s easy to gloss over that while our code runs on a version of .NET, it’s not the one we know and love. It’s different. From the official documentation:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p>Blazor WebAssembly (WASM) apps run client-side in the browser on a WebAssembly-based .NET runtime.<br />–<a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/hosting-models?view=aspnetcore-6.0#blazor-webassembly" target="_blank" rel="noreferrer noopener">Microsoft Docs</a></p>
</blockquote>



<p>And it’s also reflected in the graphic used on the page, with clear iconography indicating your new Blazor WASM app running in the browser.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="461" height="450" class="wp-image-3463 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/03/blazor.webp" alt="" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/03/blazor.webp 461w, https://topreviewhostingasp.net/wp-content/uploads/2023/03/blazor-300x293.webp 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/03/blazor-50x50.webp 50w" sizes="(max-width: 461px) 100vw, 461px" /></figure></div>


<p><strong>Well, where does the debugging happen if your app runs standalone in the client?</strong> If you answered <strong>“on the client!”</strong>, then you’d be correct. <strong>All WASM code debugging occurs in the client and is typically proxied to your IDE of choice.</strong> That means your tools need a constant connection between your integrated development environment and the client app. Being in the client also means we’re not using traditional .NET debuggers but instead relying on the debuggers found in Chrome dev-tools. Keep that in mind.</p>



<p>Let’s investigate how and where this connection can go wrong and help you debug your Blazor WASM standalone apps.</p>



<h2 class="wp-block-heading" id="chromium-web-browsers-are-required">Chromium Web Browsers Are Required</h2>



<p>Currently, Blazor WASM debugging only works with Chromium-based browsers.</p>



<ul>
<li>Google Chrome (version 70 or later)</li>
<li>Microsoft Edge (version 80 or later).</li>
</ul>



<p>These browsers have the necessary developer tools to connect and communicate with your development environment. Sorry, Firefox and Safari users. You’ll need Chrome installed.</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><a href="https://www.asphostportal.com" target="_blank" rel="noreferrer noopener"><img decoding="async" width="300" height="271" class="wp-image-2584 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2018/11/ahp-banner-aspnet-01.png" alt="" srcset="https://topreviewhostingasp.net/wp-content/uploads/2018/11/ahp-banner-aspnet-01.png 300w, https://topreviewhostingasp.net/wp-content/uploads/2018/11/ahp-banner-aspnet-01-50x45.png 50w" sizes="(max-width: 300px) 100vw, 300px" /></a></figure></div>


<h2 class="wp-block-heading" id="missing-launch-settings-fields">Missing Launch Settings Fields</h2>



<p>Most ASP.NET Core projects will come with a <code>launchSettings.json</code> file. Here we can tell the <code>dotnet</code> process how to run our web host application. However, for Blazor WASM hosts, we need a few more settings than we initially had with a vanilla ASP.NET Core app.</p>



<pre class="wp-block-code"><code>"BlazorWithBackend.Server": {
  "commandName": "Project",
  "dotnetRunMessages": true,
  "launchBrowser": true,
  "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
  "applicationUrl": "https://localhost:7174;http://localhost:5276",
  "environmentVariables": {
    "ASPNETCORE_ENVIRONMENT": "Development"
  }
}</code></pre>



<p>You’ll need an additional <code>inspectUri</code> field and an optional <code>dotnetRunMessages</code> field. The <code>inspectUri</code> field is the endpoint to which the Chromium-based browser will connect via WebSocket. Without this field, no proxy-based debugging is possible.</p>



<h2 class="wp-block-heading" id="missing-nuget-packages">Missing NuGet Packages</h2>



<p>There are two locations where you need to ensure you have NuGet packages installed correctly in your Blazor WASM solution: The client and the server.</p>



<p>The Blazor WASM client project requires you to install two NuGet packages:</p>



<ul>
<li><code>Microsoft.AspNetCore.Components.WebAssembly</code></li>
<li><code>Microsoft.AspNetCore.Components.WebAssembly.DevServer</code></li>
</ul>



<p>The <code>DevServer</code> package includes the <code>BlazorDebugProxy</code> required to connect the client and IDE. Without this package, you aren’t debugging anything.</p>



<p>The Blazor WASM host, also need the following package of <code>Microsoft.AspNetCore.Components.WebAssembly.Server</code>, which includes the necessary middleware to host your Blazor application.</p>



<h2 class="wp-block-heading" id="misconfiguration-of-blazor-middleware">Misconfiguration of Blazor Middleware</h2>



<p>You’ll need several pieces of middleware to get debugging working, specifically the <code>UseWebAssemblyDebugging</code> method call. In addition, the order of middleware registrations requires to be accurately registered. I’ve included a correct sample below from the default templates.</p>



<pre class="wp-block-code"><code>var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    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();

app.UseBlazorFrameworkFiles();
app.UseStaticFiles();
app.UseRouting();
app.MapRazorPages();
app.MapControllers();
app.MapFallbackToFile("index.html");</code></pre>



<h2 class="wp-block-heading" id="enabling-the-javascript-debugger">Enabling The JavaScript Debugger</h2>



<p>Remember how I said previously that <strong>EVERYTHING HAPPENS IN THE CLIENT</strong>? Well, you need to enable the JavaScript debugger in your favorite IDE. Personally, as a JetBrains Rider user, it’s as simple as checking the <code>with JavaScript debugger</code> checkbox found in the run configuration from your server host.</p>



<h2 class="wp-block-heading" id="running-the-correct-run-configuration">Running the Correct Run Configuration</h2>



<p>This tip is specifically for JetBrains Rider users. After enabling the JavaScript debugger, you might accidentally start the JavaScript Debugger run configuration. This allows Rider to connect to an existing running app, but doesn’t start your host application if it is not already started. This might cause your browser to launch and hang on Blazor’s “Loading” screen. If you find yourself waiting longer than you expect, double-check the run configuration you launched.</p>



<h2 class="wp-block-heading" id="globaljson-and-net-6">Global.Json and .NET 6</h2>



<p>As of writing this post, some of your IDEs only have support for .NET 6 debugging. If you have any preview versions of .NET installed, you may want to set your <code>global.json</code> file to lock the SDK version to the .NET 6 band.</p>



<h2 class="wp-block-heading" id="restart-the-chrome-instance-no-the-other-one">Restart the Chrome Instance, No The Other One</h2>



<p>So when debugging Blazor WASM apps, your IDE might start a brand-new instance of Chrome with different settings. Check your taskbar and dock for multiple instances of Chrome. Locate the one your IDE started and quit and retry the debugging process.</p>



<p>It’s common to see messages saying: <strong><em>“Blazor Wasm Debugging: lockfile exists, connecting to already running browser”</em></strong>. The message means you have the debugging instance of Chrome still running from previous attempts.</p>



<p>Shut it down and try again.</p>



<h2 class="wp-block-heading">Final Verdict</h2>



<p>I hope to give you some suggestions for getting your Blazor WASM client debugging with your favorite IDEs.</p>



<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://topreviewhostingasp.net/how-to-troubleshoot-net-blazor-wasm-debugging/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
