I am wondering if i am missing something but just started a basic template for server side Blazor and find that Console.WriteLine does not work. By that I mean I can't see the text in Chrome Console.
@code{
protected override async Task OnInitializedAsync()
{
System.Console.WriteLine("oninit");
}
}
Blazor Server Hosting Model ASP.NET Core apps can be configured to use Blazor Server as the hosting model, which means that the app is executed on the server side instead of in a browser.
In Visual Studio uppermost menu choose Debug > Windows > Output. It shows all Console. WriteLine("Debug MyVariable: " + MyVariable) when you get to them.
Server-side Blazor is executed on the server within an ASP.NET Core application. All UI updates, event handling, and JavaScript calls are handled from server by using a SignalR connection, even a button click will go to server.
Blazor is a web framework for building web UI components (Razor components) that can be hosted in different ways. Razor components can run server-side in ASP.NET Core (Blazor Server) versus client-side in the browser on a WebAssembly-based . NET runtime (Blazor WebAssembly, Blazor WASM).
I had to do something like this to make text show in the browser console:
@inject IJSRuntime jsRuntime
@code {
protected override async Task OnInitializedAsync()
{
await jsRuntime.InvokeAsync<string>("console.log", "hello world");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With