Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Blazor js interop empty DataTransfer API items after calling dotnet method

I have a Blazor server side project and I am trying to interop with js. Everything works as expected except this strange (for me) behavior

Inside a js module I have registered an ondrop event and I am assigning the dataTransfer items from the event to a const;

After awaiting the dotnet method the const items is kind of "resetting".

dropzone.addEventListener("drop", dropHandler, false);

const dropHandler = async (event) => {
    event.preventDefault();
    const items = event.dataTransfer.items;
    console.log(items);
    // outputs: DataTransferItemList {0: DataTransferItem, length: 1}
    dotnetRefObject.InvokeMethodAsync("FireAndForget");
    console.log(items);
    // outputs: DataTransferItemList {0: DataTransferItem, length: 1}
    const result = await dotnetRefObject.invokeMethodAsync('MethodWithReturn');
    console.log(result);
    //ouputs: true
    console.log(items);
    //ouputs: DataTransferItemList {length: 0}
}
[JSInvokable]
public async Task<bool> MethodWithReturn()
{
    await Task.Delay(1);
    return true;
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!