Skip to content

Commit afaccf2

Browse files
Basic passive rendering (#3)
1 parent d06bd3a commit afaccf2

34 files changed

+1410
-17
lines changed

AspNetCore.sln

+19-17
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "perf", "perf", "{74377D3E-E
17561756
EndProject
17571757
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Server.HttpSys.Microbenchmarks", "src\Servers\HttpSys\perf\Microbenchmarks\Microsoft.AspNetCore.Server.HttpSys.Microbenchmarks.csproj", "{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}"
17581758
EndProject
1759+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorUnitedApp", "src\Components\Samples\BlazorUnitedApp\BlazorUnitedApp.csproj", "{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}"
1760+
EndProject
17591761
Global
17601762
GlobalSection(SolutionConfigurationPlatforms) = preSolution
17611763
Debug|Any CPU = Debug|Any CPU
@@ -10517,22 +10519,6 @@ Global
1051710519
{A8E2AB77-8F57-47C2-A961-2F316793CAFF}.Release|x64.Build.0 = Release|Any CPU
1051810520
{A8E2AB77-8F57-47C2-A961-2F316793CAFF}.Release|x86.ActiveCfg = Release|Any CPU
1051910521
{A8E2AB77-8F57-47C2-A961-2F316793CAFF}.Release|x86.Build.0 = Release|Any CPU
10520-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10521-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
10522-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|arm64.ActiveCfg = Debug|Any CPU
10523-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|arm64.Build.0 = Debug|Any CPU
10524-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|x64.ActiveCfg = Debug|Any CPU
10525-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|x64.Build.0 = Debug|Any CPU
10526-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|x86.ActiveCfg = Debug|Any CPU
10527-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Debug|x86.Build.0 = Debug|Any CPU
10528-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
10529-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|Any CPU.Build.0 = Release|Any CPU
10530-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|arm64.ActiveCfg = Release|Any CPU
10531-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|arm64.Build.0 = Release|Any CPU
10532-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|x64.ActiveCfg = Release|Any CPU
10533-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|x64.Build.0 = Release|Any CPU
10534-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|x86.ActiveCfg = Release|Any CPU
10535-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD}.Release|x86.Build.0 = Release|Any CPU
1053610522
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1053710523
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Debug|Any CPU.Build.0 = Debug|Any CPU
1053810524
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Debug|arm64.ActiveCfg = Debug|Any CPU
@@ -10549,6 +10535,22 @@ Global
1054910535
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Release|x64.Build.0 = Release|Any CPU
1055010536
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Release|x86.ActiveCfg = Release|Any CPU
1055110537
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB}.Release|x86.Build.0 = Release|Any CPU
10538+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
10539+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|Any CPU.Build.0 = Debug|Any CPU
10540+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|arm64.ActiveCfg = Debug|Any CPU
10541+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|arm64.Build.0 = Debug|Any CPU
10542+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|x64.ActiveCfg = Debug|Any CPU
10543+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|x64.Build.0 = Debug|Any CPU
10544+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|x86.ActiveCfg = Debug|Any CPU
10545+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Debug|x86.Build.0 = Debug|Any CPU
10546+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|Any CPU.ActiveCfg = Release|Any CPU
10547+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|Any CPU.Build.0 = Release|Any CPU
10548+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|arm64.ActiveCfg = Release|Any CPU
10549+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|arm64.Build.0 = Release|Any CPU
10550+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|x64.ActiveCfg = Release|Any CPU
10551+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|x64.Build.0 = Release|Any CPU
10552+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|x86.ActiveCfg = Release|Any CPU
10553+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A}.Release|x86.Build.0 = Release|Any CPU
1055210554
EndGlobalSection
1055310555
GlobalSection(SolutionProperties) = preSolution
1055410556
HideSolutionNode = FALSE
@@ -11414,9 +11416,9 @@ Global
1141411416
{890B5210-48EF-488F-93A2-F13BCB07C780} = {4DA84F2B-1948-439B-85AB-E99E31331A9C}
1141511417
{A8E2AB77-8F57-47C2-A961-2F316793CAFF} = {890B5210-48EF-488F-93A2-F13BCB07C780}
1141611418
{F43CC5EA-6032-4A11-A9B2-6D48CB5EB082} = {4DA84F2B-1948-439B-85AB-E99E31331A9C}
11417-
{B6B74AC7-63AE-49E0-8283-C7B230BE12BD} = {33CAD745-5912-47D3-BAF3-5AE580FED275}
1141811419
{74377D3E-E0C6-41A4-89ED-11A9C00142A9} = {166E48ED-9738-4E13-8618-0D805F6F0F65}
1141911420
{3C7C65BF-0C13-418E-90BD-EC9C3CD282CB} = {74377D3E-E0C6-41A4-89ED-11A9C00142A9}
11421+
{09962BE7-48EC-44EA-B86A-3652FF0D7D1A} = {5FE1FBC1-8CE3-4355-9866-44FE1307C5F1}
1142011422
EndGlobalSection
1142111423
GlobalSection(ExtensibilityGlobals) = postSolution
1142211424
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}

src/Components/Components.slnf

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"src\\Components\\Forms\\src\\Microsoft.AspNetCore.Components.Forms.csproj",
1616
"src\\Components\\Forms\\test\\Microsoft.AspNetCore.Components.Forms.Tests.csproj",
1717
"src\\Components\\Samples\\BlazorServerApp\\BlazorServerApp.csproj",
18+
"src\\Components\\Samples\\BlazorUnitedApp\\BlazorUnitedApp.csproj",
1819
"src\\Components\\Server\\src\\Microsoft.AspNetCore.Components.Server.csproj",
1920
"src\\Components\\Server\\test\\Microsoft.AspNetCore.Components.Server.Tests.csproj",
2021
"src\\Components\\WebAssembly\\Authentication.Msal\\src\\Microsoft.Authentication.WebAssembly.Msal.csproj",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
5+
<IsShippingPackage>false</IsShippingPackage>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<Reference Include="Microsoft.AspNetCore" />
11+
<Reference Include="Microsoft.AspNetCore.Components.Server" />
12+
<Reference Include="Microsoft.AspNetCore.HttpsPolicy" />
13+
<Reference Include="Microsoft.AspNetCore.Mvc" />
14+
<Reference Include="Microsoft.Extensions.Hosting" />
15+
</ItemGroup>
16+
17+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace BlazorUnitedApp.Data;
5+
6+
public class WeatherForecast
7+
{
8+
public DateTime Date { get; set; }
9+
10+
public int TemperatureC { get; set; }
11+
12+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
13+
14+
public string Summary { get; set; } = default!;
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace BlazorUnitedApp.Data;
5+
6+
public class WeatherForecastService
7+
{
8+
private static readonly string[] Summaries = new[]
9+
{
10+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
11+
};
12+
13+
public Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)
14+
{
15+
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast
16+
{
17+
Date = startDate.AddDays(index),
18+
TemperatureC = Random.Shared.Next(-20, 55),
19+
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
20+
}).ToArray());
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
@page "/counter"
2+
3+
<PageTitle>Counter</PageTitle>
4+
5+
<h1>Counter</h1>
6+
7+
<p id="counter">Current count: @currentCount</p>
8+
9+
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
10+
11+
@code {
12+
int currentCount = 0;
13+
14+
void IncrementCount()
15+
{
16+
currentCount++;
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@page "/error"
2+
3+
4+
<h1 class="text-danger">Error.</h1>
5+
<h2 class="text-danger">An error occurred while processing your request.</h2>
6+
7+
<h3>Development Mode</h3>
8+
<p>
9+
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
10+
</p>
11+
<p>
12+
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
13+
It can result in displaying sensitive information from exceptions to end users.
14+
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
15+
and restarting the app.
16+
</p>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
@page "/fetchdata"
2+
3+
<PageTitle>Weather forecast</PageTitle>
4+
5+
@using BlazorUnitedApp.Data
6+
@inject WeatherForecastService ForecastService
7+
8+
<h1>Weather forecast</h1>
9+
10+
<p>This component demonstrates fetching data from a service.</p>
11+
12+
@if (forecasts == null)
13+
{
14+
<p><em>Loading...</em></p>
15+
}
16+
else
17+
{
18+
<table class="table">
19+
<thead>
20+
<tr>
21+
<th>Date</th>
22+
<th>Temp. (C)</th>
23+
<th>Temp. (F)</th>
24+
<th>Summary</th>
25+
</tr>
26+
</thead>
27+
<tbody>
28+
@foreach (var forecast in forecasts)
29+
{
30+
<tr>
31+
<td>@forecast.Date.ToShortDateString()</td>
32+
<td>@forecast.TemperatureC</td>
33+
<td>@forecast.TemperatureF</td>
34+
<td>@forecast.Summary</td>
35+
</tr>
36+
}
37+
</tbody>
38+
</table>
39+
}
40+
41+
@code {
42+
WeatherForecast[]? forecasts;
43+
44+
protected override async Task OnInitializedAsync()
45+
{
46+
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@page "/"
2+
3+
<PageTitle>Index</PageTitle>
4+
5+
<h1>Hello, world!</h1>
6+
7+
Welcome to your new app.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@layout MainLayout
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using BlazorUnitedApp.Data;
2+
3+
var builder = WebApplication.CreateBuilder(args);
4+
5+
// Add services to the container.
6+
builder.Services.AddSingleton<WeatherForecastService>();
7+
builder.Services.AddRazorComponents();
8+
9+
var app = builder.Build();
10+
11+
// Configure the HTTP request pipeline.
12+
if (!app.Environment.IsDevelopment())
13+
{
14+
app.UseExceptionHandler("/Error");
15+
app.UseHsts();
16+
}
17+
18+
app.UseHttpsRedirection();
19+
20+
app.UseStaticFiles();
21+
22+
app.UseRouting();
23+
24+
app.MapRazorComponents();
25+
26+
app.Run();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:54176/",
7+
"sslPort": 44328
8+
}
9+
},
10+
"profiles": {
11+
"BlazorUnitedApp": {
12+
"commandName": "Project",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
},
17+
"applicationUrl": "https://localhost:5001;http://localhost:5000"
18+
},
19+
"IIS Express": {
20+
"commandName": "IISExpress",
21+
"launchBrowser": true,
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
}
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@inherits LayoutComponentBase
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<base href="/" />
8+
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" />
9+
<link href="css/site.css" rel="stylesheet" />
10+
<link href="BlazorUnitedApp.styles.css" rel="stylesheet" />
11+
<HeadOutlet />
12+
</head>
13+
<body>
14+
<div class="page">
15+
<div class="sidebar">
16+
<NavMenu />
17+
</div>
18+
19+
<main>
20+
<div class="top-row px-4">
21+
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a>
22+
</div>
23+
24+
<article class="content px-4">
25+
@Body
26+
</article>
27+
</main>
28+
</div>
29+
30+
<div id="blazor-error-ui">
31+
An unhandled error has occurred.
32+
<a class="reload">Reload</a>
33+
<a class="dismiss">X</a>
34+
</div>
35+
</body>
36+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
}
28+
29+
.top-row a:first-child {
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
@media (max-width: 640.98px) {
35+
.top-row:not(.auth) {
36+
display: none;
37+
}
38+
39+
.top-row.auth {
40+
justify-content: space-between;
41+
}
42+
43+
.top-row a, .top-row .btn-link {
44+
margin-left: 0;
45+
}
46+
}
47+
48+
@media (min-width: 641px) {
49+
.page {
50+
flex-direction: row;
51+
}
52+
53+
.sidebar {
54+
width: 250px;
55+
height: 100vh;
56+
position: sticky;
57+
top: 0;
58+
}
59+
60+
.top-row {
61+
position: sticky;
62+
top: 0;
63+
z-index: 1;
64+
}
65+
66+
.top-row, article {
67+
padding-left: 2rem !important;
68+
padding-right: 1.5rem !important;
69+
}
70+
}

0 commit comments

Comments
 (0)