- Saved searches
- Use saved searches to filter your results more quickly
- JavaScript interop calls cannot be issued at this time. #205
- JavaScript interop calls cannot be issued at this time. #205
- Comments
- Saved searches
- Use saved searches to filter your results more quickly
- JavaScript interop calls cannot be issued at this time #24320
- JavaScript interop calls cannot be issued at this time #24320
- Comments
- Scenario
- error InvalidOperationException: JavaScript interop calls cannot be issued at this time when pass value from page to page ?
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
JavaScript interop calls cannot be issued at this time. #205
JavaScript interop calls cannot be issued at this time. #205
✔️ Resolution: Answered Resolved because the question asked by the original author has been answered.
Comments
Hi, I found that when using some components (eg modal and accordion), the following error can be found in the log (BlazorServer .NET7). This only happens the first time a page with these components is loaded. When you go to such a page on a loaded site, there is no problem.
Microsoft.AspNetCore.Server.Kestrel: Error: Connection id "0HMQL8SRMGJ30", Request id "0HMQL8SRMGJ30:00000001": An unhandled exception was thrown by the application. System.InvalidOperationException: 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. at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson, JSCallResultType resultType, Int64 targetInstanceId) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, CancellationToken cancellationToken, Object[] args) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at BlazorBootstrap.Modal.DisposeAsync(Boolean disposing) at BlazorBootstrap.Base.BaseAfterRenderComponent.DisposeAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass74_0.g__HandleAsyncExceptions|1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Components.RenderTree.Renderer.<>c__DisplayClass74_0.g__HandleAsyncExceptions|1>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Components.RenderTree.Renderer.DisposeAsync() at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.g__Await|22_0(Int32 i, ValueTask vt, List`1 toDispose) at Microsoft.AspNetCore.Http.Features.RequestServicesFeature.g__Awaited|9_0(RequestServicesFeature servicesFeature, ValueTask vt) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.g__ProcessEvents|242_0(HttpProtocol protocol, Stack`1 events) The program '[25044] NET7.BlazorServerApp.exe' has exited with code 4294967295 (0xffffffff).
It is extremely easy to reproduce, in the example for dotnet7 add code to the component, for example SurveyPrompt:
@code < private Modal? modal; // Demonstrates how a parent component can supply parameters [Parameter] public string? Title < get; set; >>
Since this component is used on the start page, we will get a problem when starting the application.
The text was updated successfully, but these errors were encountered:
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
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
JavaScript interop calls cannot be issued at this time #24320
JavaScript interop calls cannot be issued at this time #24320
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Comments
This code which is in a shared component library
@code private WeatherForecast[] forecasts; protected override async Task OnAfterRenderAsync(bool firstRender) < try < forecasts = await Http.GetFromJsonAsyncWeatherForecast[]>("WeatherForecast"); > catch (AccessTokenNotAvailableException exception) < exception.Redirect(); > > >
System.InvalidOperationException: 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. at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](String identifier, CancellationToken cancellationToken, Object[] args) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.EnsureAuthService() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.RequestAccessToken() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.AuthorizationMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts, CancellationToken callerToken, Int64 timeoutTime) at System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsyncCore[T](Task`1 taskResponse, JsonSerializerOptions options, CancellationToken cancellationToken) at FastPOS.Components.Pages.FetchData.LoadData() in H:\Projects\FastPOS\FastPOS.Components\Pages\FetchData.razor:line 50 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle) Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit '2VyNH42RzzyOWhCYqYPi1IaPI8WXWy7UBdPay-qDSOI'. System.InvalidOperationException: 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. at Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(Int64 asyncHandle, String identifier, String argsJson) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](String identifier, CancellationToken cancellationToken, Object[] args) at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](String identifier, Object[] args) at Microsoft.JSInterop.JSRuntimeExtensions.InvokeVoidAsync(IJSRuntime jsRuntime, String identifier, Object[] args) at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.EnsureAuthService() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.RemoteAuthenticationService`3.RequestAccessToken() at Microsoft.AspNetCore.Components.WebAssembly.Authentication.AuthorizationMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts, CancellationToken callerToken, Int64 timeoutTime) at System.Net.Http.Json.HttpClientJsonExtensions.GetFromJsonAsyncCore[T](Task`1 taskResponse, JsonSerializerOptions options, CancellationToken cancellationToken) at FastPOS.Components.Pages.FetchData.LoadData() in H:\Projects\FastPOS\FastPOS.Components\Pages\FetchData.razor:line 50 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle)
Scenario
I have created a project where blazor server side and blazor wasm are sharing a single component base library (I want them the evolve thogheter), there is also a server that handles authorization and authentication which is a separated project (Created from the blazor wasm with individuatl aunthetication template)
Now after some modification almost everything from the default template with individual authentication is working in both server side and wasm: login, register account, pages with @Attribute [Authorize] but they are sharing code from a single component library and they are working with the same authorization and authentication server
The problem is the Fetchdata example which is only working on wasm due the error mentioned above even after I put the code on OnAfterRenderAsync
The text was updated successfully, but these errors were encountered:
error InvalidOperationException: JavaScript interop calls cannot be issued at this time when pass value from page to page ?
I work on blazor web app with .net core 7 . I get error when try to pass user name from login page to another page dashboard after use login success.
I pass data using session storage from login page to dashboard page .
from debugging I check function after login success SetUserName(UserName) it set value of user name to NewUserName on session storage success .
error happen on dashoard.razor when I try to get User Name from sessions storage .
InvalidOperationException: 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. Microsoft.AspNetCore.Components.Server.Circuits.RemoteJSRuntime.BeginInvokeJS(long asyncHandle, string identifier, string argsJson, JSCallResultType resultType, long targetInstanceId) Microsoft.JSInterop.JSRuntime.InvokeAsync(long targetInstanceId, string identifier, CancellationToken cancellationToken, object[] args) Microsoft.JSInterop.JSRuntime.InvokeAsync(long targetInstanceId, string identifier, object[] args) System.Threading.Tasks.ValueTask.get_Result() Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync(string purpose, string key) System.Threading.Tasks.ValueTask.get_Result() System.Runtime.CompilerServices.ValueTaskAwaiter.GetResult() UC.AppRepository.UI.Pages.Dashboard.GetUserName() in Dashboard.razor + ProtectedBrowserStorageResult result = await sessionStorage.GetAsync("NewUserName"); UC.AppRepository.UI.Pages.Dashboard.OnInitializedAsync() in Dashboard.razor + await GetUserName();
public async Task Login() < string UserName = userDto.UserName; SetUserName(UserName); >private async Task SetUserName(string UserName) < await sessionStorage.SetAsync("NewUserName", UserName); NavigationManager.NavigateTo("/Dashboard", true); >DashBoard.razor(second page I need to reach to it) @inject ProtectedSessionStorage sessionStorage @code < public string? UserName < get; set; >protected override async Task OnInitializedAsync() < await GetUserName(); >> private async Task GetUserName() < ProtectedBrowserStorageResultresult = await sessionStorage.GetAsync("NewUserName"); if (result.Success) < UserFullName = result.Value; >> public async Task Login() < string UserName = userDto.UserName; SetUserName(UserName); >private async Task SetUserName(string UserName) < await sessionStorage.SetAsync("NewUserName", UserName); NavigationManager.NavigateTo("/Dashboard", true); >DashBoard.razor(second page I need to reach to it) @inject ProtectedSessionStorage sessionStorage @code < public string? UserName < get; set; >protected override async Task OnInitializedAsync() < await GetUserName(); >> private async Task GetUserName() < ProtectedBrowserStorageResultresult = await sessionStorage.GetAsync("NewUserName"); if (result.Success) < UserFullName = result.Value; >> Welcome @UserFullName