Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service worker is not being registered and rendered when .NET core 5 app is published into IIS #83

Open
htlcoil opened this issue Jul 1, 2021 · 7 comments

Comments

@htlcoil
Copy link

htlcoil commented Jul 1, 2021

Hi, the service worker is not being registered and rendered when .NET core 5 app is published into IIS.

While running the app via visual studio on IIS Express it does works but on IIS it's not.

What could be the reason?

@Darkace01
Copy link
Contributor

Can you confirm that there is no error logged in your console, also if you are using https

@MalimaMelk
Copy link

I have the same issue in .net core 3.1

@Darkace01
Copy link
Contributor

I have the same issue in .net core 3.1

Can you run your code in release mode and check if it is still registered

@david-payling-wright
Copy link

I just ran into the same issue with .NET core 3.1. Everything looked good when running locally, but then the service worker wasn't being registered after deploying to our K8S clusters.

In the 'ServiceWorkerTagHelperComponent' class (lines 38-41), I see the issue

            if ((_options.AllowHttp || _accessor.HttpContext.Request.IsHttps) || _env.IsDevelopment())
            {
                output.PostContent.AppendHtml(_script);
            }

On my local, this evaluates to 'true', so the service worker script was being added to the page. However, in our K8S clusters, this evaluates to 'false', so the service worker script was not being added

@eivinderiksen
Copy link

I just ran into the same issue with .NET core 3.1. Everything looked good when running locally, but then the service worker wasn't being registered after deploying to our K8S clusters.

In the 'ServiceWorkerTagHelperComponent' class (lines 38-41), I see the issue

            if ((_options.AllowHttp || _accessor.HttpContext.Request.IsHttps) || _env.IsDevelopment())
            {
                output.PostContent.AppendHtml(_script);
            }

On my local, this evaluates to 'true', so the service worker script was being added to the page. However, in our K8S clusters, this evaluates to 'false', so the service worker script was not being added

David: Same issue here. The IIS server is placed behind a BigIP firewall, and https is being offloaded to http, making the script tag not being rendered. Did you find any solution?

@abitzer
Copy link
Contributor

abitzer commented Apr 5, 2023

The solution would be to set AllowHttp property of the PwaOptions to true:

AllowHttp=true

Locally you most likely run your application as "Development" environment, which would make the if to evaluate to true.

@abitzer
Copy link
Contributor

abitzer commented Apr 5, 2023

Proposal to close this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants