3

I am trying to upgrade from a Blazor WASM .net5 project to .net6. I change the to net6.0 on all the projects. All compiles well, but I get a 404 error on loading blazor.webassembly.js

When I search for it from explorer I find it at: examgenerator\bin\Debug\net6.0\wwwroot_framework

while the request URL is: https://localhost:5001/_framework/blazor.webassembly.js

What am I missing?

2
  • 1
    I had this issue upgrading from 3.1 to 6 and I haven't solved it directly, I created a new project with net 6 and included all the files. I hope you have more patience than I had, so it will help others. Commented Dec 17, 2021 at 14:10
  • That is what I ended up doing. Worked well, but a pain. Commented Dec 22, 2021 at 14:25

2 Answers 2

5

It's quite easy to miss, but you need to ensure that your Client project is declared like this:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
    <TargetFramework>net6.0</TargetFramework>
    <!--The rest of your code here-->
</Project>

Notice that Microsoft.NET.Sdk.Web was changed to Microsoft.NET.Sdk.BlazorWebAssembly.


It's also important to have Microsoft.AspNetCore.Components.WebAssembly up to date.

<ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.4" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.4" PrivateAssets="all" />
</ItemGroup>

A diff tool like WinMerge is really helpful when looking for differences like this.

Note: There's a good chance that you'll run into some other issue (most likely hot reload related) while making such an upgrade. Until Microsoft comes up with a super clean solution to this, your best bet is to create a new .NET 6 project and move your code files there. This might of course be a frustrating option, but it's will save you so much more time.

Sign up to request clarification or add additional context in comments.

Comments

1

Try to check if you have updated all your Nuget packages. Had this issue as well and had it resolved when I updated all my packages, particularly the Microsoft.AspNetCore.Components.WebAssembly package.

1 Comment

Good thought, but that was one of the first things I did in converting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.