dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.43k stars 10.02k forks source link

Blazor PWA Not Able to Install After Publishing on Azure Web Service #39195

Closed theumairtahir closed 11 months ago

theumairtahir commented 2 years ago

Is there an existing issue for this?

Describe the bug

I have created an application using Blazor WebAssembly (.Net 5) named as Altanzil.org. The main feature of this application was to be offline as PWA. In the development environment it was working fine and the PWA install button was appearing accurately. But as soon as I published the application on the production using Azure, the install button is not showing and the service worker throws some integrity errors. I have explored the some other related issues on this aspect but does not find any thing to counter my issue. I have used the default service worker and method provided by the Microsoft with the template. My application link is https://altanzil.org and it is deployed on azure webapp service (windows).

Browser Console errors: Failed to find a valid digest in the 'integrity' attribute for resource 'https://altanzil.org/manifest.json' with computed SHA-256 integrity 'yVFLqAnHMupUocO8sJG2St43rtWBklEEIv8dV6DgpzI='. The resource has been blocked. Unknown error occurred while trying to verify integrity. service-worker.js:22 Uncaught (in promise) TypeError: Failed to fetch at service-worker.js:22 at async onInstall (service-worker.js:22)

One more thing I need to mention here is that the domain "altanzil.org" is forwarded to "altanzil.azurewebsites.net". Please help me in solving this issue on priority biases as I have to deliver the project to my client. Thank You.

Expected Behavior

I need a standard install button which appears on the top bar to install the PWA.

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

.net 5

Anything else?

No response

pranavkm commented 2 years ago

@ut786 I'm able to install the app using the website you listed. Were you able to resolve the integrity error you encountered? We also provide a script to help resolving integrity errors as part of our docs: https://docs.microsoft.com/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#resolve-integrity-check-failures

ghost commented 2 years ago

Hi @ut786. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

theumairtahir commented 2 years ago

@ut786 I'm able to install the app using the website you listed. Were you able to resolve the integrity error you encountered? We also provide a script to help resolving integrity errors as part of our docs: https://docs.microsoft.com/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-6.0#resolve-integrity-check-failures

@pranavkm The issue is not resolved on my side yet nor on my client's side. Can you please share me how do you accessed the URL? I am attaching my screenshot below image image

Plus I am going to check the docs you've shared with me.

pranavkm commented 2 years ago

Here you go: Screencap

I wonder if it's HTTP (over)caching that is causing this. Perhaps try deleting your application's cache from the browser, turn off network caching and retry. If that's the case you might want to consider tweaking your host to return different headers. ASP.NET Core will return Cache-Control: no-cache for the service-worker.js and service-worker-assets.js to ensure that these files are always checked for updated content.

Unrelated, I noticed that your app is returning uncompressed binaries rather than the brotli compressed ones which would mean increased app size and startup time. Have a look at https://docs.microsoft.com/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-5.0#compression,

ghost commented 2 years ago

Hi @ut786. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

theumairtahir commented 2 years ago

Here you go: Screencap

I wonder if it's HTTP (over)caching that is causing this. Perhaps try deleting your application's cache from the browser, turn off network caching and retry. If that's the case you might want to consider tweaking your host to return different headers. ASP.NET Core will return Cache-Control: no-cache for the service-worker.js and service-worker-assets.js to ensure that these files are always checked for updated content.

Unrelated, I noticed that your app is returning uncompressed binaries rather than the brotli compressed ones which would mean increased app size and startup time. Have a look at https://docs.microsoft.com/aspnet/core/blazor/host-and-deploy/webassembly?view=aspnetcore-5.0#compression,

@pranavkm I have tried your solution but It's just working on Microsoft Edge browser and only on the latest desktop version of it not the mobile version as well. It is not working on Google Chrome (either desktop or mobile) which is the standard browser for PWAs and has a vast number of users. If the application doesn't behave accurately on Chrome then we can loose interest of most of the users. I think there maybe some tags which are missing but I couldn't found them. I have also tried to add cache tags but they also not worked.

mkArtakMSFT commented 2 years ago

Thanks @ut786. We'll take a closer look at this as part of the work of updating the integrity check failures investigation docs.

ghost commented 2 years ago

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

theumairtahir commented 2 years ago

@mkArtakMSFT Thanks for adding it to the milestone. I am looking forward to it. But currently what solution should I propose to my client?

ghost commented 2 years ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

mkArtakMSFT commented 2 years ago

@ut786 is this still an issue for you or did you get to some resolution here?

ghost commented 2 years ago

Hi @ut786. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

theumairtahir commented 2 years ago

@mkArtakMSFT I somehow fixed the issue last time and it didn't reproduced on my other application. So I cannot say anything confidently here.

MackinnonBuck commented 11 months ago

Closing this out since it's not clear that there's a framework problem here. A new issue can be opened if the problem arises again.