<script src="_framework/blazor.server.js" autostart="false"></script> <script> Blazor.start().then(() => { Blazor.defaultReconnectionHandler._reconnectCallback = function (d) { // Invoke C# method from JavaScript to log the error DotNet.invokeMethodAsync('wsp.Blazor.Server.Logs', 'LogErrorFromJS', "Attempting to reconnect, Network Disconnect") .finally(() => { // Reload the page after logging the error document.location.reload(); }); }; }); console.log("testing"); </script>
namespace wsp.Blazor.Server.Logs { public static class LogTester { [JSInvokable] public static void LogErrorFromJS(string errorMessage) { // Call the logger to log the error Protokoll.GetLogger("").Error(errorMessage); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)