Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

.NET Core 3.0 preview 6 updates #9

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</table>
<div class="pagination">

<button class="btn pagebutton btn-info" onclick=@(async () => SetPagerSize("back"))>&laquo;</button>
<button class="btn pagebutton btn-secondary" onclick=@(async () => NavigateToPage("previous"))>Prev</button>
<button class="btn pagebutton btn-info" @onclick=@(async () => SetPagerSize("back"))>&laquo;</button>
<button class="btn pagebutton btn-secondary" @onclick=@(async () => NavigateToPage("previous"))>Prev</button>

@for (int i = startPage; i <= endPage; i++)
{
Expand All @@ -24,14 +24,14 @@
</button>
}

<button class="btn pagebutton btn-secondary" onclick=@(async () => NavigateToPage("next"))>Next</button>
<button class="btn pagebutton btn-info" onclick=@(async () => SetPagerSize("forward"))>&raquo;</button>
<button class="btn pagebutton btn-secondary" @onclick=@(async () => NavigateToPage("next"))>Next</button>
<button class="btn pagebutton btn-info" @onclick=@(async () => SetPagerSize("forward"))>&raquo;</button>

<span class="pagebutton btn btn-link disabled">Page @curPage of @totalPages</span>

</div>

@functions {
@code {
int totalPages;
int curPage;
int pagerSize;
Expand Down Expand Up @@ -65,7 +65,7 @@

IEnumerable<TableItem> ItemList { get; set; }

protected override async Task OnInitAsync()
protected override Task OnInitAsync()
{
pagerSize = 5;
curPage = 1;
Expand All @@ -74,6 +74,7 @@
totalPages = (int)Math.Ceiling(Items.Count() / (decimal)PageSize);

SetPagerSize("forward");
return Task.CompletedTask;
}

public void updateList(int currentPage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</table>
<div class="pagination">

<button class="btn pagebutton btn-info" onclick=@(async () => SetPagerSize("back"))>&laquo;</button>
<button class="btn pagebutton btn-secondary" onclick=@(async () => NavigateToPage("previous"))>Prev</button>
<button class="btn pagebutton btn-info" @onclick=@(async () => SetPagerSize("back"))>&laquo;</button>
<button class="btn pagebutton btn-secondary" @onclick=@(async () => NavigateToPage("previous"))>Prev</button>

@for (int i = startPage; i <= endPage; i++)
{
Expand All @@ -24,14 +24,14 @@
</button>
}

<button class="btn pagebutton btn-secondary" onclick=@(async () => NavigateToPage("next"))>Next</button>
<button class="btn pagebutton btn-info" onclick=@(async () => SetPagerSize("forward"))>&raquo;</button>
<button class="btn pagebutton btn-secondary" @onclick=@(async () => NavigateToPage("next"))>Next</button>
<button class="btn pagebutton btn-info" @onclick=@(async () => SetPagerSize("forward"))>&raquo;</button>

<span class="pagebutton btn btn-link disabled">Page @curPage of @totalPages</span>

</div>

@functions {
@code {
int totalPages;
int curPage;
int pagerSize;
Expand Down Expand Up @@ -65,7 +65,7 @@

IEnumerable<TableItem> ItemList { get; set; }

protected override async Task OnInitAsync()
protected override Task OnInitAsync()
{
pagerSize = 5;
curPage = 1;
Expand All @@ -74,6 +74,7 @@
totalPages = (int)Math.Ceiling(Items.Count() / (decimal)PageSize);

SetPagerSize("forward");
return Task.CompletedTask;
}

public void updateList(int currentPage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview4-19216-03" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview4-19216-03" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<Router AppAssembly="typeof(Program).Assembly" />
<Router AppAssembly="typeof(Program).Assembly">
<NotFoundContent>
<p>Sorry, there's nothing at this address.</p>
</NotFoundContent>
</Router>
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<OutputType>Exe</OutputType>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview6.19307.2" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BlazorGridComponent\BlazorGridComponent.csproj" />
<ProjectReference Include="..\..\..\01-Start\BlazorGridComponent\BlazorGridComponent.csproj" />
<ProjectReference Include="..\BlazorSample.Shared\BlazorSample.Shared.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<p>Current count: @currentCount</p>

<button class="btn btn-primary" onclick="@IncrementCount">Click me</button>
<button class="btn btn-primary" @onclick="@IncrementCount">Click me</button>

@functions {
@code {
int currentCount = 0;

void IncrementCount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ else
</BlazorGrid>
}

@functions {
@code {
WeatherForecast[] forecasts;

protected override async Task OnInitAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ Welcome to your new app.

<SurveyPrompt Title="How is Blazor working for you?" />

<Counter />
<Counter />
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">BlazorSample</a>
<button class="navbar-toggler" onclick="@ToggleNavMenu">
<button class="navbar-toggler" @onclick="@ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>

<div class="@NavMenuCssClass" onclick="@ToggleNavMenu">
<div class="@NavMenuCssClass" @onclick="@ToggleNavMenu">
<ul class="nav flex-column">
<li class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
Expand All @@ -25,7 +25,7 @@
</ul>
</div>

@functions {
@code {
bool collapseNavMenu = true;

string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

<span class="text-nowrap">
Please take our
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2086020">brief survey</a>
<a target="_blank" class="font-weight-bold" href="https://go.microsoft.com/fwlink/?linkid=2093904">brief survey</a>
</span>
and tell us what you think.
</div>

@functions {
@code {
// Demonstrates how a parent component can supply parameters
[Parameter] string Title { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Server" Version="3.0.0-preview6.19307.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0-preview6.19307.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseBlazorDebugging();
}

app.UseClientSideBlazorFiles<Client.Startup>();

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
endpoints.MapFallbackToClientSideBlazor<Client.Startup>("index.html");
});

app.UseBlazor<Client.Startup>();
}
}
}
49 changes: 22 additions & 27 deletions Sessions/aspNet/01-Blazor/02-End/BlazorSample/BlazorSample.sln
Original file line number Diff line number Diff line change
@@ -1,48 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28902.138
VisualStudioVersion = 16.0.29006.145
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorSample.Server", "BlazorSample.Server\BlazorSample.Server.csproj", "{2A7ADE86-30D2-434A-9DE7-FD0005BF0804}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorSample.Server", "BlazorSample.Server\BlazorSample.Server.csproj", "{AC34EC65-5EC0-4C65-AFC0-A90E6ED0B775}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorSample.Client", "BlazorSample.Client\BlazorSample.Client.csproj", "{C83C3D00-C2CF-4C29-BBFC-AE068F1AB189}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorSample.Client", "BlazorSample.Client\BlazorSample.Client.csproj", "{B94D06D0-A340-4EE1-BB0D-55A9A34D7166}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorSample.Shared", "BlazorSample.Shared\BlazorSample.Shared.csproj", "{D586CEA9-D5C8-4E83-A055-56A4AD0B4B5A}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorSample.Shared", "BlazorSample.Shared\BlazorSample.Shared.csproj", "{60C4F7DC-DD42-483B-9F72-70DB6E77B7F7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorGridComponent", "BlazorGridComponent\BlazorGridComponent.csproj", "{1CC4B0C3-1C17-4408-B93F-D151123783EF}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{4B338735-B7CC-463A-9144-356B8B9EBB65}"
ProjectSection(SolutionItems) = preProject
global.json = global.json
EndProjectSection
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorGridComponent", "..\..\01-Start\BlazorGridComponent\BlazorGridComponent.csproj", "{E6C0666E-C04A-4715-BD23-120282430D13}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2A7ADE86-30D2-434A-9DE7-FD0005BF0804}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2A7ADE86-30D2-434A-9DE7-FD0005BF0804}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A7ADE86-30D2-434A-9DE7-FD0005BF0804}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A7ADE86-30D2-434A-9DE7-FD0005BF0804}.Release|Any CPU.Build.0 = Release|Any CPU
{C83C3D00-C2CF-4C29-BBFC-AE068F1AB189}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C83C3D00-C2CF-4C29-BBFC-AE068F1AB189}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C83C3D00-C2CF-4C29-BBFC-AE068F1AB189}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C83C3D00-C2CF-4C29-BBFC-AE068F1AB189}.Release|Any CPU.Build.0 = Release|Any CPU
{D586CEA9-D5C8-4E83-A055-56A4AD0B4B5A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D586CEA9-D5C8-4E83-A055-56A4AD0B4B5A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D586CEA9-D5C8-4E83-A055-56A4AD0B4B5A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D586CEA9-D5C8-4E83-A055-56A4AD0B4B5A}.Release|Any CPU.Build.0 = Release|Any CPU
{1CC4B0C3-1C17-4408-B93F-D151123783EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1CC4B0C3-1C17-4408-B93F-D151123783EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1CC4B0C3-1C17-4408-B93F-D151123783EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1CC4B0C3-1C17-4408-B93F-D151123783EF}.Release|Any CPU.Build.0 = Release|Any CPU
{AC34EC65-5EC0-4C65-AFC0-A90E6ED0B775}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AC34EC65-5EC0-4C65-AFC0-A90E6ED0B775}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AC34EC65-5EC0-4C65-AFC0-A90E6ED0B775}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AC34EC65-5EC0-4C65-AFC0-A90E6ED0B775}.Release|Any CPU.Build.0 = Release|Any CPU
{B94D06D0-A340-4EE1-BB0D-55A9A34D7166}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B94D06D0-A340-4EE1-BB0D-55A9A34D7166}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B94D06D0-A340-4EE1-BB0D-55A9A34D7166}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B94D06D0-A340-4EE1-BB0D-55A9A34D7166}.Release|Any CPU.Build.0 = Release|Any CPU
{60C4F7DC-DD42-483B-9F72-70DB6E77B7F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{60C4F7DC-DD42-483B-9F72-70DB6E77B7F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{60C4F7DC-DD42-483B-9F72-70DB6E77B7F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{60C4F7DC-DD42-483B-9F72-70DB6E77B7F7}.Release|Any CPU.Build.0 = Release|Any CPU
{E6C0666E-C04A-4715-BD23-120282430D13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E6C0666E-C04A-4715-BD23-120282430D13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E6C0666E-C04A-4715-BD23-120282430D13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E6C0666E-C04A-4715-BD23-120282430D13}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {21081A8F-7E54-4128-9759-EF6C79573B84}
SolutionGuid = {27917031-292E-410B-B0B2-2D916BED4090}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Sessions/aspNet/01-Blazor/02-End/BlazorSample/global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "3.0.100-preview5-011568"
"version": "3.0.100-preview6-012264"
}
}
12 changes: 6 additions & 6 deletions Sessions/aspNet/01-Blazor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
![](Images/BlazorTemplates.png)

6. Show to the audience the various projects in Solution Explorer and explain their meaning:
- **BlazorGridSample.Client** is the main project and it runs completely client side thanks to WebAssembly
- **BlazorGridSample.Server** is the backend, which supports operations that can be performed only server-side, like accessing to a database
- **BlazorGridSample.Shared** is a .NET Standard library. Since both are ASP.NET Core projects, you can freely share code between the two. This project contains the definition of an entity, **WeatherForecast**, which is shared across the two.
7. Make sure **BlazorGridSample.Server** is set as startup project and press F5.
- **BlazorSample.Client** is the main project and it runs completely client side thanks to WebAssembly
- **BlazorSample.Server** is the backend, which supports operations that can be performed only server-side, like accessing to a database
- **BlazorSample.Shared** is a .NET Standard library. Since both are ASP.NET Core projects, you can freely share code between the two. This project contains the definition of an entity, **WeatherForecast**, which is shared across the two.
7. Make sure **BlazorSample.Server** is set as startup project and press F5.
8. Once the web application starts, show the various pages of the application, like Counter and Fetch Data. Interact with them, to demonstrate that everything is running client side.
9. Go back to Visual Studio 2019 and briefly show the code of the **Counter.razor** and **FetchData.razor** files in the **Pages** folder. Highlight how there’s no JavaScript, all the logic is C#.
10. As a final proof, press F12 in Edge to open the Developer tools and move to the **Network** tab.
11. Reload the page by pressing CTRL-R
12. Show to the audience how the web application is not loading only HTML, CSS and JavaScript files, but also .dll and .wasm files:
- Call out specifically **mono.wasm**, which is the web assembly implementation of Mono leveraged by Blazor.
- Call out specifically **BlazorGridSample.Client.dll**, which is the application built in Visual Studio.
- Call out specifically **BlazorSample.Client.dll**, which is the application built in Visual Studio.

![](Images/DeveloperTools.png)

Expand All @@ -40,7 +40,7 @@
19. Open the **FetchData.razor** file under **Pages** and show to the audience how the table is manually built using a foreach loop on the weather forecasts collection.
20. Now right click on the solution in Visual Studio and choose **Add -> Existing project**.
21. Look for the **BlazorGridComponent.csproj** file inside the folder **01-Blazor\01-Start\BlazorGridComponent** and select it
22. Now right click on the **BlazorGridSample.Client** project and choose **Add reference**.
22. Now right click on the **BlazorSample.Client** project and choose **Add reference**.
23. Choose **Projects -> Solution** and select the **BlazorGridComponent** project you have just added.
24. Now go back to the **FetchData.razor** file in the **Pages** folder
25. Add, at the top of the file, the following statement:
Expand Down
Loading