Skip to content

Commit c6bcac8

Browse files
authored
Merge branch 'main' into guardrex/blazor-http-context-coverage
2 parents f3313a2 + e76a9db commit c6bcac8

File tree

47 files changed

+829
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+829
-123
lines changed

aspnetcore/blazor/components/index.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -817,10 +817,10 @@ In the following `ParameterChild` component, component parameters include:
817817
> [!WARNING]
818818
> Providing initial values for component parameters is supported, but don't create a component that writes to its own parameters after the component is rendered for the first time. For more information, see <xref:blazor/components/overwriting-parameters>.
819819
820-
The component parameters of the `ParameterChild` component can be set by arguments in the HTML tag that renders an instance of the `ParameterChild` component. The following `ParameterParent` component renders two `ParameterChild` components:
820+
The component parameters of the `ParameterChild` component can be set by arguments in the HTML tag that renders an instance of the `ParameterChild` component. The following parent component renders two `ParameterChild` components:
821821

822822
* The first `ParameterChild` component is rendered without supplying parameter arguments.
823-
* The second `ParameterChild` component receives values for `Title` and `Body` from the `ParameterParent` component, which uses an [explicit C# expression](xref:mvc/views/razor#explicit-razor-expressions) to set the values of the `PanelBody`'s properties.
823+
* The second `ParameterChild` component receives values for `Title` and `Body` from the parent component, which uses an [explicit C# expression](xref:mvc/views/razor#explicit-razor-expressions) to set the values of the `PanelBody`'s properties.
824824

825825
:::moniker range=">= aspnetcore-9.0"
826826

@@ -870,7 +870,7 @@ The component parameters of the `ParameterChild` component can be set by argumen
870870

871871
:::moniker-end
872872

873-
The following rendered HTML markup from the `ParameterParent` component shows `ParameterChild` component default values when the `ParameterParent` component doesn't supply component parameter values. When the `ParameterParent` component provides component parameter values, they replace the `ParameterChild` component's default values.
873+
The following rendered HTML markup from the parent component shows `ParameterChild` component default values when the parent component doesn't supply component parameter values. When the parent component provides component parameter values, they replace the `ParameterChild` component's default values.
874874

875875
> [!NOTE]
876876
> For clarity, most of the rendered CSS style classes and some elements aren't shown in the following rendered HTML markup. The main concept demonstrated by the following example is that the parent component assigned values to the child component using its component parameters.
@@ -895,7 +895,7 @@ Assign a C# field, property, or result of a method to a component parameter as a
895895

896896
If the component parameter is of type string, then the attribute value is instead treated as a C# string literal. If you want to specify a C# expression instead, then use the `@` prefix.
897897

898-
The following `ParameterParent2` component displays four instances of the preceding `ParameterChild` component and sets their `Title` parameter values to:
898+
The following parent component displays four instances of the preceding `ParameterChild` component and sets their `Title` parameter values to:
899899

900900
* The value of the `title` field.
901901
* The result of the `GetTitle` C# method.

aspnetcore/blazor/debug.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,6 @@ Breakpoints can also be hit in the server project.
222222

223223
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
224224

225-
**Start Without Debugging** [<kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS)] isn't supported. When the app is run in Debug configuration, debugging overhead always results in a small performance reduction.
226-
227225
---
228226

229227
:::moniker-end
@@ -254,8 +252,6 @@ Breakpoints are **not** hit during app startup before the debug proxy is running
254252

255253
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
256254

257-
**Start Without Debugging** [<kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS)] isn't supported. When the app is run in Debug configuration, debugging overhead always results in a small performance reduction.
258-
259255
---
260256

261257
:::moniker-end
@@ -285,8 +281,6 @@ Breakpoints are **not** hit during app startup before the debug proxy is running
285281

286282
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
287283

288-
**Start Without Debugging** [<kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS)] isn't supported. When the app is run in Debug configuration, debugging overhead always results in a small performance reduction.
289-
290284
---
291285

292286
:::moniker range="< aspnetcore-8.0"
@@ -317,8 +311,6 @@ You can also debug server code in the **:::no-loc text="Server":::** project:
317311

318312
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
319313

320-
**Start Without Debugging** [<kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS)] isn't supported. When the app is run in Debug configuration, debugging overhead always results in a small performance reduction.
321-
322314
# [Visual Studio Code](#tab/visual-studio-code)
323315

324316
> [!NOTE]
@@ -336,8 +328,6 @@ Publishing an app disables debugger support. To debug a published, hosted Blazor
336328
> [!WARNING]
337329
> Published, hosted Blazor WebAssembly apps should only enable debugging and copying output symbols when deploying published assets ***locally***. Don't deploy a published app into a production environment with the `DebuggerSupport` and `CopyOutputSymbolsToPublishDirectory` properties set to `true`.
338330
339-
**Start Without Debugging** [<kbd>Ctrl</kbd>+<kbd>F5</kbd> (Windows) or <kbd>⌘</kbd>+<kbd>F5</kbd> (macOS)] isn't supported. When the app is run in Debug configuration, debugging overhead always results in a small performance reduction.
340-
341331
---
342332

343333
:::moniker-end

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,58 @@ app.MapBlazorHub();
15071507
+ app.MapBlazorHub("/signalr");
15081508
```
15091509

1510+
## Impersonation for Windows Authentication
1511+
1512+
Authenticated hub connections (<xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>) are created with <xref:Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionOptions.UseDefaultCredentials%2A> to indicate the use of default credentials for HTTP requests. For more information, see <xref:signalr/authn-and-authz#windows-authentication>.
1513+
1514+
When the app is running in IIS Express as the signed-in user under Windows Authentication, which is likely the user's personal or work account, the default credentials are those of the signed-in user.
1515+
1516+
When the app is published to IIS, the app runs under the *Application Pool Identity*. The <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection> connects as the IIS "user" account hosting the app, not the user accessing the page.
1517+
1518+
Implement *impersonation* with the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection> to use the identity of the browsing user.
1519+
1520+
In the following example:
1521+
1522+
* The user from the authentication state provider is cast to a <xref:System.Security.Principal.WindowsIdentity>.
1523+
* The identity's access token is passed to <xref:System.Security.Principal.WindowsIdentity.RunImpersonatedAsync%2A?displayProperty=nameWithType> with the code that builds and starts the <xref:Microsoft.AspNetCore.SignalR.Client.HubConnection>.
1524+
1525+
```csharp
1526+
protected override async Task OnInitializedAsync()
1527+
{
1528+
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
1529+
1530+
if (authState?.User.Identity is not null)
1531+
{
1532+
var user = authState.User.Identity as WindowsIdentity;
1533+
1534+
if (user is not null)
1535+
{
1536+
await WindowsIdentity.RunImpersonatedAsync(user.AccessToken,
1537+
async () =>
1538+
{
1539+
hubConnection = new HubConnectionBuilder()
1540+
.WithUrl(NavManager.ToAbsoluteUri("/hub"), config =>
1541+
{
1542+
config.UseDefaultCredentials = true;
1543+
})
1544+
.WithAutomaticReconnect()
1545+
.Build();
1546+
1547+
hubConnection.On<string>("name", userName =>
1548+
{
1549+
name = userName;
1550+
InvokeAsync(StateHasChanged);
1551+
});
1552+
1553+
await hubConnection.StartAsync();
1554+
});
1555+
}
1556+
}
1557+
}
1558+
```
1559+
1560+
In the preceding code, `NavManager` is a <xref:Microsoft.AspNetCore.Components.NavigationManager>, and `AuthenticationStateProvider` is an <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationStateProvider> service instance ([`AuthenticationStateProvider` documentation](xref:blazor/security/authentication-state)).
1561+
15101562
## Additional server-side resources
15111563

15121564
* [Server-side host and deployment guidance: SignalR configuration](xref:blazor/host-and-deploy/server#signalr-configuration)

0 commit comments

Comments
 (0)