Skip to content

Bad Response + Manifest: Line: 1, column: 1, Syntax error. + Failed to register a ServiceWorker #86

@Becca37

Description

@Becca37

Issue: getting error Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://localhost:44376/') with script ('https://localhost:44376/serviceworker'): A bad HTTP response code (500) was received when fetching the script.
localhost/:1

I see a couple of references to this set of errors, but each issue refers back to a closed issue, and that closed issue appears to have been deleted. So, I'm hoping someone can point me in the right direction for me to find my error. TIA! :0)

  • ASP NET Core 5.0
  • C#
  • Razor Pages
  • running on localhost using HTTPS

Stuff ...

  • If I put the manifest.json's location in the browser address bar, it displays the file fine.
  • I have turned off Javascript debugging via Tools > Options > Debugging > General
  • I have the checkbox Update on reload checked in developer tools > application > service workers
  • After running, a serviceworker in present at developer tools > application > service workers and shows (and remains the same except for the incrementing numer if I unregister it and reload the page):
Received 12/31/1969 7:00:00 pm 
Status #dddd is redundant

manifest.json in wwwroot folder:

{
	"name": "App Name",
	"short_name": "AppAcronym",
	"icons":
	[
		{
			"src": "/images/manifest/icons-192.png",
			"type": "image/png",
			"sizes": "192x192"
		},
		{
			"src": "/images/manifest/icons-512.png",
			"type": "image/png",
			"sizes": "512x512"
		}
	],
	"start_url": "/",
	"background_color": "#17a2b8",
	"display": "standalone",
	"scope": "/",
	"theme_color": "#17a2b8"
}

Startup.cs addition, items removed for berevity; services.AddMvc() added only to troubleshoot as some internet references suggested that might be the answer; no change in behavior for me:

		{
			services.AddRazorPages();
			services.AddMvc();
			services.AddProgressiveWebApp();
		}

view page source after building and running shows expected entries in head and at end of body:

<meta name="theme-color" content="#17a2b8" />
<link rel="manifest" href="/manifest.webmanifest" />
<script nws-csp-add-nonce='true'>'serviceWorker'in navigator&&navigator.serviceWorker.register('/serviceworker', { scope: '/' })</script>

errors in Chrome developer console:

A bad HTTP response code (500) was received when fetching the script.
localhost/:1 

GET https://localhost:44376/manifest.webmanifest 500

manifest.webmanifest:1 Manifest: Line: 1, column: 1, Syntax error.
localhost/:1 

Uncaught (in promise) TypeError: Failed to register a ServiceWorker for scope ('https://localhost:44376/') with script ('https://localhost:44376/serviceworker'): A bad HTTP response code (500) was received when fetching the script.
localhost/:1 

GET https://localhost:44376/manifest.webmanifest 500
manifest.webmanifest:1 

Manifest: Line: 1, column: 1, Syntax err

Ideas? Suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions