Failed to find a valid digest in the 'integrity' attribute for resource in Blazor app

Viewed 16231

I have a Blazor client/server app that I have been working on for a period and it has been working fine up to now. I suddenly started getting this error

Failed to find a valid digest in the 'integrity' attribute for resource 'https://mydomain.no/_framework/Faso.Blazor.SpinKit.dll' with computed SHA-256 integrity '1UEuhA1KzEN0bQcoU0m1eL4WKcCIWHhPgoXydAJnO9w='. The resource has been blocked.

Failed to find a valid digest in the 'integrity' attribute for resource

I have tried to clean and rebuild. I have tried to add Cors, set folder permission, and many other suggested solutions, but to no avail. I am using web deploy in VS 2022 and Win Server 2016, .net core 5.0.

Any suggestions would be appreciated.

5 Answers

This is an annoying issue indeed and I'm getting that error every now and then. It seems to happen after updating some packages, and the build processes fails to pick up the new SHA for the package.

You can verify that this is the issue by finding the file containing the SHAs and compare the SHA for the dll in question with the SHA from the error message. This file is called blazor.boot.json and is generated deep inside the obj-folder of your project folder. (mine was here: obj\Release\net6.0\win-x86\PubTmp\Out\wwwroot\_framework)

If was the issue, please try this:

  1. Close VS.
  2. Delete the obj and bin folders from all your projects. (the web project might be enough, but hey - can't hurt)
  3. Start VS
  4. Rebuild solution.
  5. Try Publish again.

Check this note from: https://docs.microsoft.com/en-us/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0

Resolve integrity check failures: When Blazor WebAssembly downloads an app's startup files, it instructs the browser to perform integrity checks on the responses. Blazor sends SHA-256 hash values for DLL (.dll), WebAssembly (.wasm), and other files in the blazor.boot.json file, which isn't cached on clients. The file hashes of cached files are compared to the hashes in the blazor.boot.json file. For cached files with a matching hash, Blazor uses the cached files. Otherwise, files are requested from the server. After a file is downloaded, its hash is checked again for integrity validation. An error is generated by the browser if any downloaded file's integrity check fails.

If after deleted obj and bin folders the error continues, be sure that you are deleting the cache on your client browser of the site (Ctrl + F5)

All answers here are great.

The only caveat to my solution was that I was using a hosted Blazor WASM model. Since we publish our Server application, it takes the liberty to build the Client for us. After seeing every single solution say to delete your bin and obj folder and then banging my head on every wall in our office it finally dawned on me that I don't need to be deleting the bin and obj from my "Server" project and that I might need to go to the Client project and do that.

It might sound simple enough in hindsight, but coffee failed me this morning. At the expense of my pride.. hopefully this can be someone's light bulb answer. Sometimes YOU are the little things. :D

I finally solved it for my own issue! This issue has been plaguing me for weeks.

I had tried all of the things mentioned here and elsewhere, and none of it worked. What did work was using my ftp client (filezilla) and changing the transfer type from "auto" to "binary" (Transfer > Transfer Type > Binary). I don't see an option for doing this in VS2022, so I guess I'll use my manual ftp client solution for now.

Aaaahhhhh.

My solution is also so interesting. I put my web api service and Blazor Wasm projects into same server with different subdomains. Both of them are using .Net 6.
Although Web Api works well, Blazor gave that error. I tried everything on the StackOverflow, none of them worked. Then I tried to move Blazor project to another server that another Blazor Wasm is already working and Bingo!
While it gave problem in Windows Server 2022 with IIS 10.0.20348.1 and .Net Core Hosting Bundle 6.0.7; it worked in first try with the same files in Windows Server 2019 with IIS 10.0.17763.1 and .Net Core Hosting Bundle 6.0.6
I am really so surprised that why it gave error in new server and I couldn't understand where is the problem exactly (Server edition, IIS or .Net minor version differences)
I hope it helps to someone that couldn't solve problem yet.

Related