Replies: 4 comments
-
I've just come across this. I am using the Blazor Web App template, full WASM. This is my Program.cs in the Host/Server project. using Blazored.LocalStorage;
using MudBlazor.Services;
using OneWorkList.Components;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddMudServices();
builder.Services.AddBlazoredLocalStorage();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseWebAssemblyDebugging();
}
else
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveWebAssemblyRenderMode()
.AddAdditionalAssemblies(typeof(OneWorkList.Client._Imports).Assembly);
app.Run(); Results in
I have tried using I've seen @chrissainty mention in a previous issue that they will wait for .NET8 to be out for a little while before releasing updates to this library to work with it. So I think for now, we won't be able to use it using the new .NET8 Web App version of Blazor. |
Beta Was this translation helpful? Give feedback.
-
You guys might be able to disable prerendering to get this to work. That can be done on the component tag. Alternately, does anybody know of another library that does what this one does? |
Beta Was this translation helpful? Give feedback.
-
This is expected behaviour in .NET8. In fact it's very similar behaviour Blazor has always had. You can't call a JS runtime that doesn't exist. If you're using the new templates and have pre-rendering the error is telling you the solution. Make the call in OnAfterRender(Async). |
Beta Was this translation helpful? Give feedback.
-
Thanks Chris!
…On Sat, Feb 3, 2024, 10:41 AM Chris Sainty ***@***.***> wrote:
This is expected behaviour in .NET8. In fact it's very similar behaviour
Blazor has always had. You can't call a JS runtime that doesn't exist.
If you're using the new templates and have pre-rendering the error is
telling you the solution. Make the call in OnAfterRender(Async).
—
Reply to this email directly, view it on GitHub
<#231 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AX7D2AKGBMTWUEN5WJZOHILYRZLBZAVCNFSM6AAAAABAAQY7KCVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DGNJVGU2DK>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
On Server Program.cs:
builder.Services.AddBlazoredLocalStorage();
Page:
It shows the error:
JavaScript interop calls cannot be issued at this time. This is because the component is being statically rendered. When prerendering is enabled, JavaScript interop calls can only be performed during the OnAfterRenderAsync lifecycle method.
The same applied to Client Project:
Beta Was this translation helpful? Give feedback.
All reactions