Closed JapstersCavern closed 6 months ago
MetaMask.Blazor was primarily designed to work with Blazor WASM. The ConnectMetaMask invokes JavaScript on the client to see if the MetaMask plugin is installed. This is not something that can run on the server. So I think you need to make sure all of this code runs on the client side.
Doesn't it use JSRuntime.InvokeAsync to call through to the browser?
That should work on Blazor Server once OnAfterRender has executed.
I added a new sample to show usage when using RenderMode InteractiveWebAssembly
located here: https://github.com/michielpost/MetaMask.Blazor/tree/master/Metamask.Blazor.SampleWebApp
Can you try it?
Maybe the problem is only in the debugger detachting and Visual Studio stopping the web app. I've seen that before, for example when triggering file downloads.
Thanks for this help, Michiel - I'll take a look and see if it works for my scenario!
Once again, many thanks!
After forking your repo and putting breakpoints into the js and cs it seems it crashes after Blazor invokes requestAccounts
.
If I connect and allow access to a wallet then the Visual Studio debugger session just stops immediately. Oddly though, if the server is run with dotnet run
then there are no problems at all. So it looks like it might be a problem with the Visual Studio debugger.
Thanks for your time!!
I'm just trying out your library, and really appreciate you making this available!
I'm experiencing a confusing problem. When I try to connect to Metamask in a Blazor server app (.Net 8), and the user clicks cancel, then the Blazor server app terminates even though I have a 'catch' block to catch all exceptions.
This is my code:
I don't understand how this is crashing the server - Do you have any suggestions please?