Open scearces opened 6 years ago
Same problem here. I believe the 'Update Constants.cs #29' commit is the issue.
Going back to 1.0.33 fixed the issue, it's working again!
Same problem here. Going back to 1.0.33 fixed the issue for me also.
I know it's not ideal but if you disable registering both the service worker and manifest:
services.AddProgressiveWebApp(new PwaOptions
{
RegisterServiceWorker = false,
RegisterWebmanifest = false,
OfflineRoute = "offline"
});
You can then manually add both back to your layout:
<meta name="theme-color" content="#FFFFFF" />
<link rel="manifest" href="/manifest.webmanifest" />
and
<script>'serviceWorker' in navigator && navigator.serviceWorker.register('/serviceworker')</script>
Facing same issue. Using other way around by setting RegisterServiceWorker
and RegisterWebmanifest
to false
and adding both file manually as mentioned by @jpisano
@madskristensen It appears the latest WebEssentials.AspNetCore.SPA NuGet package doesn't work with .NET Core 2.1 because of the tilde, as described in the first post in this thread.
Having the same issue.
the last nuget package Version=1.0.42.0 has also again this error the master branch source are public const string ServiceworkerRoute = "/serviceworker"; the reflected one is "~/serviceworker" with dll Version=1.0.42.0
Same issue with .NET Core 2.1
Thanks!
I was wondering if anyone has the status on this issue? Found a couple potential workarounds but if there's a plan to push a NuGet update for a fix I'd be fine waiting for that.
Thanks for any update.
Thanks for keeping me in the loop. I’d be interested in the workarounds and any info on a possible NuGet update.
From: Caden Sumner notifications@github.com Sent: Wednesday, February 6, 2019 2:47 PM To: madskristensen/WebEssentials.AspNetCore.ServiceWorker WebEssentials.AspNetCore.ServiceWorker@noreply.github.com Cc: scearces stevenscearce@hotmail.com; Author author@noreply.github.com Subject: Re: [madskristensen/WebEssentials.AspNetCore.ServiceWorker] Error with .NET Core 2.1 and Razor Pages (#36)
I was wondering if anyone has the status on this issue? Found a couple potential workarounds but if there's a plan to push a NuGet update for fix I'd be fine waiting for that.
Thanks for any update.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/madskristensen/WebEssentials.AspNetCore.ServiceWorker/issues/36#issuecomment-461161305, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AnKx1YqxEv64gTOTqH_v5tZK8kx5j3Akks5vKzE2gaJpZM4VJoHH.
May be is a similar issue and that is the reason to ask here. I have follow code which is using RazorViewEngine to return compiled string when apply the model:
using (var output = new StringWriter())
{
var viewContext = new ViewContext(
actionContext,
view,
new ViewDataDictionary<TModel>(
metadataProvider: new EmptyModelMetadataProvider(),
modelState: new ModelStateDictionary())
{
Model = model
},
new TempDataDictionary(
actionContext.HttpContext,
_tempDataProvider),
output,
new HtmlHelperOptions());
await view.RenderAsync(viewContext);
return output.ToString();
}
All parameters are correct and it is working perfect when services.AddProgressiveWebApp() is not applied. But when you add it:
Unhandled Exception: System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.) ---> System.NullReferenceException: Object reference not set to an instance of an object. at WebEssentials.AspNetCore.Pwa.ServiceWorkerTagHelperComponent.Process(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.TagHelpers.TagHelperComponent.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Mvc.Razor.TagHelpers.TagHelperComponentTagHelper.ProcessAsync(TagHelperContext context, TagHelperOutput output) at Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner.RunAsync(TagHelperExecutionContext executionContext) at AspNetCore._Views__EmailLayout.ExecuteAsync() at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageCoreAsync(IRazorPage page, ViewContext context) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderPageAsync(IRazorPage page, ViewContext context, Boolean invokeViewStarts) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderLayoutAsync(ViewContext context, ViewBufferTextWriter bodyWriter) at Microsoft.AspNetCore.Mvc.Razor.RazorView.RenderAsync(ViewContext context) at Mvc.RenderViewToString.RazorViewToStringRenderer.RenderViewToStringAsync[TModel](String viewName, TModel model) in D:\Projects\TFS\GetTaxSolutions\Tools\MailKit Client\SendMailKit\TazorToString\RazorViewToStringRenderer.cs:line 58 --- End of inner exception stack trace --- at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at Mvc.RenderViewToString.Program.Main() in D:\Projects\TFS\GetTaxSolutions\Tools\MailKit Client\SendMailKit\TazorToString\Program.cs:line 24 Press any key to continue . . .
I tried to apply PWA options to:
RegisterServiceWorker = false, RegisterWebmanifest = false,
It's working but is not good solution for me. Is there some better solution to resolve this issue? Are you planning to fix it in next version?
AspNetCore version: 2.2 Pwa: 1.0.49 Thanks
My configuration: localhost, Windows 10, Visual Studio 2017, ASP.NET Core 2.1, Razor Pages. The WebEssentials.AspNetCore.PWA package injects 2 lines into _Layout.cshtml. The first line, in the head, should be link rel="manifest" href="/manifest.webmanifest" /. Instead, in my configuration it generates link rel="manifest" href=" ~ /manifest.webmanifest" /. See the extra tilde . This causes chrome to fail to locate the manifest.webmanifest. The second line it injects, in html region, should be script nws-csp-add-nonce='true'>'serviceWorker' in navigator && navigator.serviceWorker.register('/serviceworker') /script. Instead it is injecting script nws-csp-add-nonce='true' 'serviceWorker'in navigator&&navigator.serviceWorker.register('~/serviceworker') /script>. Again, see the tilde. This cause the service worker registration to fail be cause Chrome can't locate it. My question is what do I need to do to make it generate the code correctly? Is it because I am using .NET Core 2.1 instead of .NET Core 2.0 or is there something else I need to change? Thanks.