diff --git a/TestApp02.sln b/TestApp02.sln new file mode 100644 index 0000000..3ac471e --- /dev/null +++ b/TestApp02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33213.308 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp02", "TestApp02\TestApp02.csproj", "{A78C4A7C-3D9B-4149-9583-2024B689D766}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A78C4A7C-3D9B-4149-9583-2024B689D766}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A78C4A7C-3D9B-4149-9583-2024B689D766}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A78C4A7C-3D9B-4149-9583-2024B689D766}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A78C4A7C-3D9B-4149-9583-2024B689D766}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {3E21C979-3355-43D6-B91E-872F83AF6A84} + EndGlobalSection +EndGlobal diff --git a/TestApp02/App.razor b/TestApp02/App.razor new file mode 100644 index 0000000..843f201 --- /dev/null +++ b/TestApp02/App.razor @@ -0,0 +1,11 @@ + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
\ No newline at end of file diff --git a/TestApp02/Data/WeatherForecast.cs b/TestApp02/Data/WeatherForecast.cs new file mode 100644 index 0000000..8a0d10e --- /dev/null +++ b/TestApp02/Data/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace TestApp02.Data +{ + public class WeatherForecast + { + public DateTime Date { get; set; } + + public int TemperatureC { get; set; } + + public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); + + public string? Summary { get; set; } + } +} diff --git a/TestApp02/Data/WeatherForecastService.cs b/TestApp02/Data/WeatherForecastService.cs new file mode 100644 index 0000000..23c0e87 --- /dev/null +++ b/TestApp02/Data/WeatherForecastService.cs @@ -0,0 +1,21 @@ +namespace TestApp02.Data +{ + public class WeatherForecastService + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + public Task GetForecastAsync(DateTime startDate) + { + var rng = new Random(); + return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast + { + Date = startDate.AddDays(index), + TemperatureC = rng.Next(-20, 55), + Summary = Summaries[rng.Next(Summaries.Length)] + }).ToArray()); + } + } +} diff --git a/TestApp02/Pages/Counter.razor b/TestApp02/Pages/Counter.razor new file mode 100644 index 0000000..0cc164c --- /dev/null +++ b/TestApp02/Pages/Counter.razor @@ -0,0 +1,17 @@ +@page "/counter" + +Counter + +Counter +Current count: @currentCount +Click me + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/TestApp02/Pages/Error.cshtml b/TestApp02/Pages/Error.cshtml new file mode 100644 index 0000000..1271259 --- /dev/null +++ b/TestApp02/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model TestApp02.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+
+
+ + + diff --git a/TestApp02/Pages/Error.cshtml.cs b/TestApp02/Pages/Error.cshtml.cs new file mode 100644 index 0000000..020a4f1 --- /dev/null +++ b/TestApp02/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace TestApp02.Pages +{ + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [IgnoreAntiforgeryToken] + public class ErrorModel : PageModel + { + public string? RequestId { get; set; } + + public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); + + private readonly ILogger _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/TestApp02/Pages/FetchData.razor b/TestApp02/Pages/FetchData.razor new file mode 100644 index 0000000..0f33fc9 --- /dev/null +++ b/TestApp02/Pages/FetchData.razor @@ -0,0 +1,42 @@ +@page "/fetchdata" +@using TestApp02.Data +@inject WeatherForecastService ForecastService + +Weather forecast + +Weather forecast +This component demonstrates fetching data from the server. +@if (forecasts == null) +{ + +} +else +{ + + + Date + Temp. (C) + Temp. (F) + Summary + + + @context.Date + @context.TemperatureC + @context.TemperatureF + @context.Summary + + + + + +} + + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + forecasts = await ForecastService.GetForecastAsync(DateTime.Now); + } +} diff --git a/TestApp02/Pages/Index.razor b/TestApp02/Pages/Index.razor new file mode 100644 index 0000000..7994d54 --- /dev/null +++ b/TestApp02/Pages/Index.razor @@ -0,0 +1,7 @@ +@page "/" + +Index + +Hello, world! +Welcome to your new app, powered by MudBlazor! +You can find documentation and examples on our website here: www.mudblazor.com diff --git a/TestApp02/Pages/_Host.cshtml b/TestApp02/Pages/_Host.cshtml new file mode 100644 index 0000000..8b2532a --- /dev/null +++ b/TestApp02/Pages/_Host.cshtml @@ -0,0 +1,8 @@ +@page "/" +@namespace TestApp02.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@{ + Layout = "_Layout"; +} + + \ No newline at end of file diff --git a/TestApp02/Pages/_Layout.cshtml b/TestApp02/Pages/_Layout.cshtml new file mode 100644 index 0000000..2bbb223 --- /dev/null +++ b/TestApp02/Pages/_Layout.cshtml @@ -0,0 +1,31 @@ +@using Microsoft.AspNetCore.Components.Web +@namespace TestApp02.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + + + + @RenderBody() + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/TestApp02/Program.cs b/TestApp02/Program.cs new file mode 100644 index 0000000..d3cbf13 --- /dev/null +++ b/TestApp02/Program.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Hosting.StaticWebAssets; +using MudBlazor.Services; +using TestApp02.Data; + +var builder = WebApplication.CreateBuilder(args); + +StaticWebAssetsLoader.UseStaticWebAssets(builder.Environment, builder.Configuration); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor(); +builder.Services.AddSingleton(); +builder.Services.AddMudServices(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); \ No newline at end of file diff --git a/TestApp02/Properties/launchSettings.json b/TestApp02/Properties/launchSettings.json new file mode 100644 index 0000000..d1ff10e --- /dev/null +++ b/TestApp02/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:61949", + "sslPort": 44393 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "TestApp02": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/TestApp02/Shared/MainLayout.razor b/TestApp02/Shared/MainLayout.razor new file mode 100644 index 0000000..05fd2f9 --- /dev/null +++ b/TestApp02/Shared/MainLayout.razor @@ -0,0 +1,34 @@ +@inherits LayoutComponentBase + + + + + + + + + + + + + + + TestApp02 + + + + + + @Body + + + + +@code { + bool _drawerOpen = true; + + void DrawerToggle() + { + _drawerOpen = !_drawerOpen; + } +} \ No newline at end of file diff --git a/TestApp02/Shared/NavMenu.razor b/TestApp02/Shared/NavMenu.razor new file mode 100644 index 0000000..0772484 --- /dev/null +++ b/TestApp02/Shared/NavMenu.razor @@ -0,0 +1,5 @@ + + Home + Counter + Fetch data + diff --git a/TestApp02/TestApp02.csproj b/TestApp02/TestApp02.csproj new file mode 100644 index 0000000..e477502 --- /dev/null +++ b/TestApp02/TestApp02.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/TestApp02/TestApp02.sln b/TestApp02/TestApp02.sln new file mode 100644 index 0000000..da59da8 --- /dev/null +++ b/TestApp02/TestApp02.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31717.71 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApp02", "TestApp02.csproj", "{42F60A9C-C0B5-45D1-8375-151FCF1B76E9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {42F60A9C-C0B5-45D1-8375-151FCF1B76E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {42F60A9C-C0B5-45D1-8375-151FCF1B76E9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {42F60A9C-C0B5-45D1-8375-151FCF1B76E9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {42F60A9C-C0B5-45D1-8375-151FCF1B76E9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {1D3B3BEB-C060-4713-84B0-051D04A1E7FE} + EndGlobalSection +EndGlobal \ No newline at end of file diff --git a/TestApp02/_Imports.razor b/TestApp02/_Imports.razor new file mode 100644 index 0000000..cdc74ec --- /dev/null +++ b/TestApp02/_Imports.razor @@ -0,0 +1,11 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using MudBlazor +@using TestApp02 +@using TestApp02.Shared diff --git a/TestApp02/appsettings.Development.json b/TestApp02/appsettings.Development.json new file mode 100644 index 0000000..5173757 --- /dev/null +++ b/TestApp02/appsettings.Development.json @@ -0,0 +1,10 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/TestApp02/appsettings.json b/TestApp02/appsettings.json new file mode 100644 index 0000000..d9d9a9b --- /dev/null +++ b/TestApp02/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/TestApp02/wwwroot/favicon.ico b/TestApp02/wwwroot/favicon.ico new file mode 100644 index 0000000..1239223 Binary files /dev/null and b/TestApp02/wwwroot/favicon.ico differ