title: Angular PWA in ASP.Net Core Server - Serviceworker-Cache not working
body: <p>I created a Angular PWA and moved it into a ASP.Net Core Spa - Application. I can run it offline when served and installed via "npm http-server".</p>
  
  <p>When I run it in the ASP.Net Server the Serviceworker loads with an error "Cannot read property 'put' of undefined" in ngsw-worker.js:</p>
  
  <pre><code>        write(key, value) {
            return this.cache.put(this.request(key), this.adapter.newResponse(JSON.stringify(value)));
          }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/AR42W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AR42W.png" alt="enter image description here"></a></p>
  
  <p>I am trying to cache requests from the webapi and configured them in the ngsw-config.json - file</p>
  
  <pre><code>    {
        "$schema": "./node_modules/@angular/service-worker/config/schema.json",
        "index": "/index.html",
        "dataGroups": [
          {
            "name": "api-freshness",
            "urls": [
              "/odata/**"
            ],
            "cacheConfig": {
              "strategy": "freshness",
              "maxSize": 500,
              "maxAge": "3d",
              "timeout": "2s"
            }
          }
        ],
        "assetGroups": [
          {
            "name": "app",
            "installMode": "prefetch",
            "resources": {
              "files": [
                "/favicon.ico",
                "/index.html",
                "/*.css",
                "/*.js"
              ]
            }
          },
          {
            "name": "assets",
            "installMode": "lazy",
            "updateMode": "prefetch",
            "resources": {
              "files": [
                "/assets/**",
                "/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
              ]
            }
          }
        ]
      }
  </code></pre>
  
  <p>In the first place the manifest.webmanifest file was served with wrong content-type, so I added a provider in my startup.cs. But this didn't help.</p>
  
  <pre><code>        provider.Mappings[".webmanifest"] = "application/manifest+json";
  
          app.UseSpaStaticFiles(new StaticFileOptions() {
              ContentTypeProvider = provider
          });
  </code></pre>