
Get client connection information
More for system log tracking
The injection service displays client information
Demo
Introduction to usage
1. The UseBootstrapBlazor
middleware in the Startup.cs file that client information collection is performed.
public void Configure(IApplicationBuilder app)
{
// ...
// 增加下面这一行
app.UseBootstrapBlazor();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapBlazorHub();
endpoints.MapFallbackToPage("/_Host");
});
}
2. The component uses the injection service WebClientService
to call the GetClientInfo
method.
[Inject]
[NotNull]
private WebClientService? ClientService { get; set; }
private ClientInfo? ClientInfo { get; set; }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
ClientInfo = await ClientService.GetClientInfo();
StateHasChanged();
}
}
B station related video link
交流群