I'm calling a C# method from Javascript using invokeMethodAsync. I had it working a day ago but it has broken since and no amount of reverting my changes seems to fix it.
Error: System.ArgumentException: The assembly 'HelloWorld' does not contain a public invokable method with [JSInvokableAttribute("GetCodeFromList")].
The JS:
DotNet.invokeMethodAsync('HelloWorld', 'GetCodeFromList')
.then(data => {
data.push(result.codeResult.code);
}
);
The result.codeResult.code is the number I want to receive on the C# side. I have already confirmed that the number is correct.
The C#:
[JSInvokable]
public void GetCodeFromList(long jsCode)
{
code = codes.Where(p => p.SecretCode.Equals(jsCode)).FirstOrDefault();
StateHasChanged();
}
I have another .razor file where I have a method also called GetCodeFromList that I also want to be accessible using the same invoke, but I have tried completely removing it and that didn't solve the problem.