Skip to content

Commit 8d2033f

Browse files
chrissaintydanroth27
authored andcommitted
Updated to RC, updated notes/docs and fixed build errors around auth
1 parent 24bab1c commit 8d2033f

File tree

14 files changed

+51
-37
lines changed

14 files changed

+51
-37
lines changed

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project>
22
<PropertyGroup>
33
<AspNetCoreVersion>3.1.3</AspNetCoreVersion>
4-
<BlazorVersion>3.2.0-preview3.20168.3</BlazorVersion>
4+
<BlazorVersion>3.2.0-rc1.20223.4</BlazorVersion>
55
<EntityFrameworkVersion>3.1.3</EntityFrameworkVersion>
6-
<SystemNetHttpJsonVersion>3.2.0-preview3.20175.8</SystemNetHttpJsonVersion>
6+
<SystemNetHttpJsonVersion>3.2.0-rc1.20217.1</SystemNetHttpJsonVersion>
77
</PropertyGroup>
88
</Project>

docs/06-authentication-and-authorization.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static async Task Main(string[] args)
5151
var builder = WebAssemblyHostBuilder.CreateDefault(args);
5252
builder.RootComponents.Add<App>("app");
5353

54-
builder.Services.AddBaseAddressHttpClient();
54+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
5555
builder.Services.AddScoped<OrderState>();
5656

5757
// Add auth services
@@ -516,8 +516,10 @@ To configure the authentication system to use our `PizzaAuthenticationState` ins
516516

517517
```csharp
518518
// Add auth services
519-
builder.Services.AddRemoteAuthentication<RemoteAuthenticationState, ApiAuthorizationProviderOptions>();
520-
builder.Services.AddApiAuthorization();
519+
builder.Services.AddApiAuthorization<PizzaAuthenticationState>(options =>
520+
{
521+
options.ProviderOptions.ConfigurationEndpoint = "_configuration/BlazingPizza.Client"; // temporary workaround
522+
});
521523
```
522524

523525
Now we need to add logic to persist the current order, and then reestablish the current order from the persisted state after the user has successfully logged in. To do that, update the `Authentication` component to use `RemoteAuthenticatorViewCore` instead of `RemoteAuthenticatorView`. Override `OnInitialized` to setup the order state to be persisted, and implement the `OnLogInSucceeded` callback to reestablish the order state. You'll need to add a `RepaceOrder` method to `OrderState` so that you can reestablish the saved order.
@@ -589,8 +591,7 @@ But what if we want the user to be redirected back to the home page after they l
589591

590592
```csharp
591593
// Add auth services
592-
builder.Services.AddRemoteAuthentication<PizzaAuthenticationState, ApiAuthorizationProviderOptions>();
593-
builder.Services.AddApiAuthorization(options =>
594+
builder.Services.AddApiAuthorization<PizzaAuthenticationState>(options =>
594595
{
595596
options.AuthenticationPaths.LogOutSucceededPath = "";
596597
options.ProviderOptions.ConfigurationEndpoint = "_configuration/BlazingPizza.Client"; // temporary workaround

notes/speaker-notes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This is a rough guide of what topics are best to introduce with each section.
1717
- Show the Router component in App.razor
1818
- Introduce `@code` - this is like the old `@functions` feature from `.cshtml`. Get users comfortable with the idea of defining properties, fields, methods, even nested classes
1919
- Components are stateful so have a place to keep state in components is useful
20-
- Introduce parameters - parameters should be non-public
20+
- Introduce parameters - parameters should be public
2121
- Introduce using a component from markup in razor - show how to pass parameters
2222
- Introduce @inject and DI - can show how that's a shorthand for a property in @code
2323
- Introduce http + JSON in Blazor (`GetFromJsonAsync`)

save-points/00-get-started/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517

1618
await builder.Build().RunAsync();
1719
}

save-points/01-Components-and-layout/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517

1618
await builder.Build().RunAsync();
1719
}

save-points/02-customize-a-pizza/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517

1618
await builder.Build().RunAsync();
1719
}

save-points/03-show-order-status/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517

1618
await builder.Build().RunAsync();
1719
}

save-points/04-refactor-state-management/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517
builder.Services.AddScoped<OrderState>();
1618

1719
await builder.Build().RunAsync();

save-points/05-checkout-with-validation/BlazingPizza.Client/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
22
using Microsoft.Extensions.DependencyInjection;
3+
using System;
4+
using System.Net.Http;
35
using System.Threading.Tasks;
46

57
namespace BlazingPizza.Client
@@ -11,7 +13,7 @@ public static async Task Main(string[] args)
1113
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1214
builder.RootComponents.Add<App>("app");
1315

14-
builder.Services.AddBaseAddressHttpClient();
16+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1517
builder.Services.AddScoped<OrderState>();
1618

1719
await builder.Build().RunAsync();

save-points/06-authentication-and-authorization/BlazingPizza.Client/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
22
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
33
using Microsoft.Extensions.DependencyInjection;
4+
using System;
5+
using System.Net.Http;
46
using System.Threading.Tasks;
57

68
namespace BlazingPizza.Client
@@ -12,12 +14,11 @@ public static async Task Main(string[] args)
1214
var builder = WebAssemblyHostBuilder.CreateDefault(args);
1315
builder.RootComponents.Add<App>("app");
1416

15-
builder.Services.AddBaseAddressHttpClient();
17+
builder.Services.AddTransient(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
1618
builder.Services.AddScoped<OrderState>();
1719

1820
// Add auth services
19-
builder.Services.AddRemoteAuthentication<PizzaAuthenticationState, ApiAuthorizationProviderOptions>();
20-
builder.Services.AddApiAuthorization(options =>
21+
builder.Services.AddApiAuthorization<PizzaAuthenticationState>(options =>
2122
{
2223
options.AuthenticationPaths.LogOutSucceededPath = "";
2324
options.ProviderOptions.ConfigurationEndpoint = "_configuration/BlazingPizza.Client"; // temporary workaround

0 commit comments

Comments
 (0)