Wrong result using InvokeAsync
See original GitHub issueDescribe the bug
While trying to send an array of objects from Blazor Client Side project to JavaScript using InvokeAsync - I am actually receiving only 1 object from the array.
To Reproduce
Steps to reproduce the behavior:
- Using this version of ASP.NET Core ‘3.0.’
- Run this code
@inherits LayoutComponentBase
@inject IJSRuntime JsRuntime;
<div class="main">
<div class="top-row px-4">
<button @onclick="IncrementCount">Click me</button>
</div>
</div>
@code
{
private async void IncrementCount()
{
List<object> cc = new List<object>();
for( int c = 0; c < 100; c++ )
{
cc.Add( new { cccc = c, dfddd = 45, dsfdsf = 54 } );
}
Console.WriteLine( cc.ToArray().Length );
await JsRuntime.InvokeAsync<object>( "sendData", cc.ToArray() );
}
}
xxxx.js
function sendData( e )
{
console.log(e);
}
- See error - the console will show only 1 object, not the array
Expected behavior
To receive the full array of objects
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Wrong result using InvokeAsync · Issue #15254
Describe the bug While trying to send an array of objects from Blazor Client Side project to JavaScript using InvokeAsync - I am...
Read more >Why does 'InvokeAsync' show as an error in a Blazor ...
1 Answer 1 · you have created/moved the code behind file TransactionTableView.razor.cs in another folder than the TransactionTableView.razor (as ...
Read more >Thread safety using InvokeAsync
After creating a new Blazor server-side application, add a static class that will store an integer value that can be accessed by multiple...
Read more >Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >Issue with invokeasync in blazor
Isonline return false because invokeAsync return false before complete the Onload event. I need return value after complete js function.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for contacting us, @YordanYanakiev. We’ll investigate this as soon as we get to it and update this thread.
Oh. I see. Then it’s fine I’ll just keep this in mind. Thank You very much for the clarification and spend time ! 😃