question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong result using InvokeAsync

See original GitHub issue

Describe 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:

  1. Using this version of ASP.NET Core ‘3.0.’
  2. 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);    
}

  1. See error - the console will show only 1 object, not the array

Expected behavior

To receive the full array of objects

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mkArtakMSFTcommented, Oct 22, 2019

Thanks for contacting us, @YordanYanakiev. We’ll investigate this as soon as we get to it and update this thread.

0reactions
YordanYanakievcommented, Oct 23, 2019

Oh. I see. Then it’s fine I’ll just keep this in mind. Thank You very much for the clarification and spend time ! 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found