Skip to content

Commit 8eb64b3

Browse files
committed
Merge branch 'net6.0' of https://github.com/dodyg/practical-aspnetcore into net6.0
2 parents c65cfcf + fe64a51 commit 8eb64b3

22 files changed

+272
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Samples for ASP.NET Core 6.0 (475)
1+
# Samples for ASP.NET Core 6.0 (476)
22

3-
Samples for ASP.NET Core **8.0 Preview 6** is available [here](/projects/.net8) (13).
3+
Samples for ASP.NET Core **8.0 Preview 7** is available [here](/projects/.net8) (14).
44

55
Samples for ASP.NET Core **7.0** is available [here](/projects/.net7) (45).
66

projects/.net8/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# ASP.NET 8.0 Preview 6 (13)
1+
# ASP.NET 8.0 Preview 7 (14)
22

3-
These samples require [.NET 8.0 Preview 6](https://github.com/dotnet/installer#table).
3+
These samples require [.NET 8.0 Preview 7](https://github.com/dotnet/installer#table).
44

55
* [QuickGrid One](QuickGridOne)
66

@@ -52,3 +52,9 @@ These samples require [.NET 8.0 Preview 6](https://github.com/dotnet/installer#t
5252
* [SlimBuilder](slim-builder)
5353

5454
`WebApplication.CreateSlimBuilder` creates `WebApplicationBuilder` with minimal configuration defaults.
55+
56+
## Blazor SSR Form Handling
57+
58+
* [RazorFormHandling](RazorFormHandling)
59+
60+
This example shows how to perfom manual data binding for a form `POST` request using `FormDataProvider`.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"dotnet.defaultSolution": "RazorComponentEight.sln"
3+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
6+
<title>Blazor Multi Render</title>
7+
<base href="/" />
8+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9ndCyUaIbzAi2FUVXJi0CjmCapSmO7SnpJef0486qhLnuZ2cdeRhO02iuK6FUUVM" crossorigin="anonymous">
9+
<HeadOutlet />
10+
</head>
11+
<body>
12+
<Router AppAssembly="@typeof(App).Assembly">
13+
<Found Context="routeData">
14+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
15+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
16+
</Found>
17+
<NotFound>
18+
<PageTitle>Not found</PageTitle>
19+
<LayoutView Layout="@typeof(MainLayout)">
20+
<p role="alert">Sorry, there's nothing at this address.</p>
21+
</LayoutView>
22+
</NotFound>
23+
</Router>
24+
25+
<script src="_framework/blazor.web.js" suppress-error="BL9992"></script>
26+
</body>
27+
</html>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@page "/"
2+
3+
<h1>Blazor Multi Render</h1>
4+
5+
@_message
6+
7+
<div class="row">
8+
<div class="col-md-4">
9+
<p class="mb-3">
10+
This button will not work because this Razor component is statically rendered
11+
</p>
12+
<button type="button" class="btn btn-primary" @onclick="ShowMessage">Show Message</button>
13+
</div>
14+
<div class="col-md-4">
15+
<Numbers />
16+
</div>
17+
<div class="col-md-4">
18+
<p class="mb-3">
19+
This button will work because this Razor component is powered by Server Side Blazor
20+
</p>
21+
<Interactive />
22+
</div>
23+
</div>
24+
25+
@code {
26+
string _message = string.Empty;
27+
28+
void ShowMessage()
29+
{
30+
_message = "This won't work";
31+
}
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
@attribute [RenderModeWebAssembly]
2+
3+
@_message
4+
5+
<button type="button" class="btn btn-primary" @onclick="ShowMessage">Show Message</button>
6+
7+
@code {
8+
string _message = string.Empty;
9+
10+
void ShowMessage()
11+
{
12+
_message = "Current Time UTC " + DateTime.UtcNow;
13+
}
14+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@attribute [StreamRendering(true)]
2+
3+
@if (_numbers is null)
4+
{
5+
<p>Loading numbers (wait for 6 seconds) ...</p>
6+
}
7+
else
8+
{
9+
<ul>
10+
@foreach(var i in _numbers)
11+
{
12+
<li>@i</li>
13+
}
14+
</ul>
15+
}
16+
17+
@code
18+
{
19+
List<int> _numbers;
20+
21+
protected override async Task OnInitializedAsync()
22+
{
23+
await Task.Delay(6_000); //six seconds
24+
25+
_numbers = Enumerable.Range(0,100).ToList();
26+
}
27+
}
28+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.AspNetCore.Components.Web;
2+
3+
var builder = WebApplication.CreateBuilder();
4+
builder.Services.AddRazorComponents()
5+
.AddServerComponents()
6+
.AddWebAssemblyComponents();
7+
8+
var app = builder.Build();
9+
app.MapRazorComponents<RazorComponentEight.App>()
10+
.AddWebAssemblyRenderMode();
11+
12+
app.Run();
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Razor Component multi render
2+
3+
This sample shows the ability for Blazor to host components with different rendering mode in a single Razor Component Page.
4+
5+
The Razor Component Page is server side render. It hosts "number" component with with Streaming rendering and hosts "interactive" component backed by Blazor Server Side.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<ImplicitUsings>true</ImplicitUsings>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0-preview.7.*" />
8+
</ItemGroup>
9+
</Project>

0 commit comments

Comments
 (0)