<?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 tutorial &#8211; ASP.NET Hosting Reviews and Guides</title>
	<atom:link href="https://topreviewhostingasp.net/tag/blazor-tutorial/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, 16 Jun 2023 08:08:55 +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 tutorial &#8211; ASP.NET Hosting Reviews and Guides</title>
	<link>https://topreviewhostingasp.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How Lazyloading Works to Increase Your Blazor Performance?</title>
		<link>https://topreviewhostingasp.net/implement-lazyloading-increase-blazor-website-performance/</link>
					<comments>https://topreviewhostingasp.net/implement-lazyloading-increase-blazor-website-performance/#respond</comments>
		
		<dc:creator><![CDATA[Jacques Hunt]]></dc:creator>
		<pubDate>Fri, 16 Jun 2023 08:08:55 +0000</pubDate>
				<category><![CDATA[Hosting Tips]]></category>
		<category><![CDATA[blazor]]></category>
		<category><![CDATA[blazor performance]]></category>
		<category><![CDATA[blazor tutorial]]></category>
		<category><![CDATA[blzor tips]]></category>
		<category><![CDATA[implement lazyloading]]></category>
		<category><![CDATA[increase blazor speed]]></category>
		<category><![CDATA[lazyloading blazor]]></category>
		<guid isPermaLink="false">https://topreviewhostingasp.net/?p=3575</guid>

					<description><![CDATA[In this article, we&#8217;ll examine how to implement lazy loading using Blazor WebAssembly. We can speed up the startup of our Blazor WebAssembly application by delaying the download of resources we don&#8217;t currently require. For instance, downloading all the files pertaining to products, authentication, and other things is useless if we have a large Blazor [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>In this article, we&#8217;ll examine how to implement lazy loading using Blazor WebAssembly. We can speed up the startup of our Blazor WebAssembly application by delaying the download of resources we don&#8217;t currently require. For instance, downloading all the files pertaining to products, authentication, and other things is useless if we have a large Blazor WebAssembly application and our users only want to view the home or contact pages. The program will only download these resources if the user specifically requests them when lazy loading is enabled.</p>
<h2>Setup Blazor WASM Project</h2>
<p>Open the Visual Studio and search for Blazor App. Click on the Next button,</p>
<p><img fetchpriority="high" decoding="async" class=" wp-image-3576 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-min.jpg" alt="" width="604" height="316" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-min.jpg 742w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-min-300x157.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-min-50x26.jpg 50w" sizes="(max-width: 604px) 100vw, 604px" /></p>
<p>Define the project name, path, and solution name. Click on the Create button,</p>
<p><img decoding="async" class=" wp-image-3577 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/project-min.jpg" alt="" width="528" height="359" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/project-min.jpg 666w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/project-min-300x204.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/project-min-50x34.jpg 50w" sizes="(max-width: 528px) 100vw, 528px" /></p>
<p>After that a new window will pop up to choose the target framework (<strong>.Net 6.0</strong>) from the dropdown and make sure to select the Blazor server App and in the Advanced section &#8220;<em>Configure the Https</em>&#8221; is checked.</p>
<p><img decoding="async" class="wp-image-3578 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-setup-min.jpg" alt="" width="648" height="421" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-setup-min.jpg 850w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-setup-min-300x195.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-setup-min-768x499.jpg 768w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-setup-min-50x32.jpg 50w" sizes="(max-width: 648px) 100vw, 648px" /></p>
<h2>Blazor Wasm Standard Workflow</h2>
<p>If we now launch our application, access the Dev Tools window (F12), select the Application tab, and check the cache:</p>
<p><img loading="lazy" decoding="async" class="wp-image-3579 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-2-min.jpg" alt="" width="692" height="457" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-2-min.jpg 850w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-2-min-300x198.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-2-min-768x507.jpg 768w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-2-min-50x33.jpg 50w" sizes="(max-width: 692px) 100vw, 692px" /></p>
<p>Although we are still on the Home page and have not navigated anywhere else, we can see that our BlazorWasmLazyLoading.dll file has been downloaded and cached, which is typical. However, it also suggests that all of the components in this DLL have been downloaded. Of course, for small apps like this one, this is not a problem. However, it could significantly speed up downloads for a more complex application. So let&#8217;s work out a way to prevent it.</p>
<h2>Updating the primary project with new packages</h2>
<p>We&#8217;re going to use the Syncfusion Libraries in this article to work with the idea of lazy loading, so create a new Razor class library project called Weather and empty it out except for the <code>_Imports.razor</code> file. Additionally, this project needs to be referenced from the main one.</p>
<p>From the right-click menu of the project, choose Manage NuGet Packages.<br />
Afterward, use the word Syncfusion. Blazor, locate, and set up the proper Syncfusion.Blazor. Blazor NuGet packages. In this location, Syncfusion has been installed. The program makes use of the NuGet packages Syncfusion and Blazor Buttons.Blazor.Calendars. Look at the illustration below.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3580" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-3-min.jpg" alt="" width="850" height="222" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-3-min.jpg 850w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-3-min-300x78.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-3-min-768x201.jpg 768w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-3-min-50x13.jpg 50w" sizes="(max-width: 850px) 100vw, 850px" /></p>
<p>Configure the Syncfusion Blazor Service in Program.cs file as per the below code.</p>
<pre>using LazyLoading;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Syncfusion.Blazor;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add&lt;App&gt;("#app");
builder.RootComponents.Add&lt;HeadOutlet&gt;("head::after");

builder.Services.AddScoped(sp =&gt; new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
builder.Services.AddSyncfusionBlazor();

await builder.Build().RunAsync();</pre>
<h2>Implementation Lazy Loading</h2>
<p>In order to use Blazor WebAssembly&#8217;s Lazy Loading feature, we must first make a change to the main project file. Therefore, from the context menu, right-click on the BlazorWasmLazyLoading project and choose EditProjectFile:</p>
<p><strong>LazyLoading.csproj</strong></p>
<pre class="">&lt;Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly"&gt;

  &lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;net6.0&lt;/TargetFramework&gt;
    &lt;Nullable&gt;enable&lt;/Nullable&gt;
    &lt;ImplicitUsings&gt;enable&lt;/ImplicitUsings&gt;
  &lt;/PropertyGroup&gt;

  &lt;ItemGroup&gt;
    &lt;PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.1" /&gt;
    &lt;PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.1" PrivateAssets="all" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Buttons" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Calendars" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Charts" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Data" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.DropDowns" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Grid" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Lists" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Navigations" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Notifications" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Popups" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.Spinner" Version="19.4.0.48" /&gt;
    &lt;PackageReference Include="Syncfusion.Blazor.SplitButtons" Version="19.4.0.48" /&gt;
  &lt;/ItemGroup&gt;
        &lt;ItemGroup&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Buttons.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Calendars.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Charts.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Data.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.DropDowns.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Grids.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Lists.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Navigations.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Notifications.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Popups.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.Spinner.dll" /&gt;
                 &lt;BlazorWebAssemblyLazyLoad Include="Syncfusion.Blazor.SplitButtons.dll" /&gt;
        &lt;/ItemGroup&gt;
        &lt;ItemGroup&gt;
          &lt;ProjectReference Include="..\Sample\Sample.csproj" /&gt;
        &lt;/ItemGroup&gt;
        &lt;ItemGroup&gt;
                &lt;BlazorWebAssemblyLazyLoad Include="Sample.dll" /&gt;
        &lt;/ItemGroup&gt;
&lt;/Project&gt;</pre>
<h2>Modifying App.razor File to Load the Required DLL</h2>
<p>We import the required utilizing directives before injecting the AssemblyLoader to load our assembly. The OnNavigateAsync event callback in the Router component is then given the OnNavigateAsync method. The OnNavigateAsync event callback is invoked just before switching to a new page. The AdditionalAssemblies property is also set to true. This attribute instructs our program to use additional assemblies to search for components that match the correct URIs.</p>
<p>In the @code section, we create the _lazyLoadedAssemblies private list of assemblies and the OnNavigateAsync method with the NavigationContext parameter. We check the currently required route inside the procedure using the context argument. If the fetch data route—the route of our FetchData component—matches, we use the LoadAssembliesAsync method to load the assemblies.</p>
<pre class="lang:default decode:true ">@using System.Reflection;
@using Microsoft.AspNetCore.Components.Routing;
@using Microsoft.AspNetCore.Components.WebAssembly.Services;
@inject LazyAssemblyLoader assemblyLoader;
&lt;Router AppAssembly="@typeof(App).Assembly" PreferExactMatches="@true" AdditionalAssemblies="@lazyLoadedAssemblies" OnNavigateAsync="@OnNavigateAsync"&gt;
    &lt;Found Context="routeData"&gt;
        &lt;RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /&gt;
        &lt;FocusOnNavigate RouteData="@routeData" Selector="h1" /&gt;
    &lt;/Found&gt;
    &lt;NotFound&gt;
        &lt;PageTitle&gt;Not found&lt;/PageTitle&gt;
        &lt;LayoutView Layout="@typeof(MainLayout)"&gt;
            &lt;p role="alert"&gt;Sorry, there's nothing at this address.&lt;/p&gt;
        &lt;/LayoutView&gt;
    &lt;/NotFound&gt;
&lt;/Router&gt;

@code {
    private List&lt;Assembly&gt; lazyLoadedAssemblies = new List&lt;Assembly&gt;();
    private async Task OnNavigateAsync(NavigationContext args)
    {
        try
        {
            if (args.Path.StartsWith("fetchdata"))
            {
                var assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Sample.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Buttons.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Charts.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Data.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.DropDowns.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Grid.dll" });
                lazyLoadedAssemblies.AddRange(assemblies);
            }
            if(args.Path.StartsWith("counter"))
            {
                var assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Calendars.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Buttons.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Lists.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Navigations.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Notifications.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Popups.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.Spinner.dll" });
                assemblies = await assemblyLoader.LoadAssembliesAsync(new[] { "Syncfusion.Blazor.SplitButtons.dll" });
                lazyLoadedAssemblies.AddRange(assemblies);
            }
        }
        catch (Exception ex)
        {

        }
    }
}</pre>
<p>Keep in mind that we won&#8217;t be able to locate the downloaded Sample.dll if we launch the app and search the cache. However, if we visit the FetchData page and the counter page, we can see the content of each page as well as the dependencies that have been downloaded.</p>
<p><img loading="lazy" decoding="async" class="wp-image-3581 aligncenter" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-4-min.jpg" alt="" width="773" height="388" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-4-min.jpg 850w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-4-min-300x151.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-4-min-768x386.jpg 768w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-4-min-50x25.jpg 50w" sizes="(max-width: 773px) 100vw, 773px" /></p>
<p><strong>Counter page</strong></p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-3582" src="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-5-min.jpg" alt="" width="850" height="427" srcset="https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-5-min.jpg 850w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-5-min-300x151.jpg 300w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-5-min-768x386.jpg 768w, https://topreviewhostingasp.net/wp-content/uploads/2023/06/blazor-5-min-50x25.jpg 50w" sizes="(max-width: 850px) 100vw, 850px" /></p>
<h2>Conclusion</h2>
<p>Currently, we are aware of how to load various dependencies solely when necessary using Blazor WebAssembly&#8217;s lazy loading feature. As was already mentioned, this is a great feature because it speeds up the loading of our application.</p>
<p>All there is to it is that!</p>
]]></content:encoded>
					
					<wfw:commentRss>https://topreviewhostingasp.net/implement-lazyloading-increase-blazor-website-performance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<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 loading="lazy" 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 loading="lazy" 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>
