URLDownloadToCacheFile Error with ClickOnce
I am trying to distribute a Windows WPF application using ClickOnce in Visual Studio 2022. I have published the set up files successfully, but when I go to the download page and click on the install button and run the setup.exe I get an error message that refers me to an error log which tells me:
URLDownloadToCacheFile failed with HRESULT '-2146697202'
Error: An error occurred trying to download 'https://www.blah.com/publish/blah.application'.
There is nothing wrong with the URL. If I copy and paste it into my browser I can download and run the file with no issues. Also, if I ignore the Install button and click on the "launch" link instead, then this downloads the blah.application application file correctly.
I have tried the download using Chrome and Edge with the same result. I have also tried it from a couple of different machines.
I have read various posts about this but most of them involve changing browser settings that as far as I can tell are obsolete.
Any help with this would be gratefully received.