12 | Request ID: @RequestId
13 |
18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |
20 |21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |
26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /BlazorWebApp/BlazorWebApp/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using BlazorWebApp 10 | @using BlazorWebApp.Client 11 | @using BlazorWebApp.Components 12 | -------------------------------------------------------------------------------- /BlazorWebApp/BlazorWebApp/Program.cs: -------------------------------------------------------------------------------- 1 | using BlazorWebApp.Client; 2 | using BlazorWebApp.Components; 3 | using BlazorPro.BlazorSize; 4 | using TestComponents; 5 | 6 | var builder = WebApplication.CreateBuilder(args); 7 | 8 | // Add services to the container. 9 | 10 | builder.Services.AddRazorComponents() 11 | .AddInteractiveServerComponents() 12 | .AddInteractiveWebAssemblyComponents(); 13 | builder.Services.AddResizeListener(); 14 | builder.Services.AddMediaQueryService(); 15 | builder.Services.AddScoped9 | Swapping to Development environment will display more detailed information about the error that occurred. 10 |
11 |12 | The Development environment shouldn't be enabled for deployed applications. 13 | It can result in displaying sensitive information from exceptions to end users. 14 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 15 | and restarting the app. 16 |
-------------------------------------------------------------------------------- /TestComponents/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @inject IWeatherForecastService Forecasts 2 | @using TestComponents 3 | @page "/fetchdata" 4 | 5 |This component demonstrates adaptive rendering of a Blazor UI.
8 | 9 | @if (IsSmall) 10 | { 11 |This component demonstrates adaptive rendering of a Blazor UI.
9 | 10 |Loading...
4 | } 5 | else 6 | { 7 | foreach (var t in Data.Select((x,i) => new { Forecast = x, Index = i })) 8 | { 9 |14 | @t.Forecast.TemperatureC (C) / @t.Forecast.TemperatureF (F) 15 |
16 |17 | @t.Forecast.Summary 18 |
19 |Loading...
4 | } 5 | else 6 | { 7 |Date | 11 |Temp. (C) | 12 |Temp. (F) | 13 |Summary | 14 |
---|---|---|---|
@forecast.Date.ToShortDateString() | 21 |@forecast.TemperatureC | 22 |@forecast.TemperatureF | 23 |@forecast.Summary | 24 |