Skip to content

Commit ef9206e

Browse files
authored
Merge pull request #34915 from dotnet/main
2 parents f0b41c2 + bfcf5fd commit ef9206e

19 files changed

Lines changed: 154 additions & 31 deletions

File tree

.github/policies/issueManagement-notTriaged.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ configuration:
1515
* 'needs-more-info' label removed
1616
if:
1717
- payloadType: Issues
18+
- not:
19+
isAssignedToUser:
20+
user: guardrex
1821
- or:
1922
2023
- or:

aspnetcore/blazor/components/render-components-outside-of-aspnetcore.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,22 @@ uid: blazor/components/render-outside-of-aspnetcore
1616

1717
In the following example, a Razor component is rendered to an HTML string from a console app:
1818

19-
In a command shell, create a new console app project:
19+
In a command shell, create a new console app project and change the directory to the `ConsoleApp1` folder:
2020

2121
```dotnetcli
2222
dotnet new console -o ConsoleApp1
2323
cd ConsoleApp1
2424
```
2525

26-
In a command shell in the `ConsoleApp1` folder, add package references for <xref:Microsoft.AspNetCore.Components.Web?displayProperty=fullName> and <xref:Microsoft.Extensions.Logging?displayProperty=fullName> to the console app:
26+
Add a package reference for <xref:Microsoft.AspNetCore.Components.Web?displayProperty=fullName>:
2727

2828
```dotnetcli
2929
dotnet add package Microsoft.AspNetCore.Components.Web
30+
```
31+
32+
Add a package reference for <xref:Microsoft.Extensions.Logging?displayProperty=fullName>:
33+
34+
```dotnetcli
3035
dotnet add package Microsoft.Extensions.Logging
3136
```
3237

@@ -48,17 +53,15 @@ Add the following `RenderMessage` component to the project.
4853
4954
@code {
5055
[Parameter]
51-
public string Message { get; set; }
56+
public string? Message { get; set; }
5257
}
5358
```
5459

55-
Update the `Program` file:
60+
Replace the code in the `Program` file with the following code:
5661

5762
* Set up dependency injection (<xref:Microsoft.Extensions.DependencyInjection.IServiceCollection>/<xref:Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider%2A>) and logging (<xref:Microsoft.Extensions.DependencyInjection.LoggingServiceCollectionExtensions.AddLogging%2A>/<xref:Microsoft.Extensions.Logging.ILoggerFactory>).
5863
* Create an <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer> and render the `RenderMessage` component by calling <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A>.
5964

60-
Any calls to <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A> must be made in the context of calling `InvokeAsync` on a component dispatcher. A component dispatcher is available from the <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.Dispatcher?displayProperty=nameWithType> property.
61-
6265
```csharp
6366
using Microsoft.AspNetCore.Components;
6467
using Microsoft.AspNetCore.Components.Web;
@@ -93,6 +96,8 @@ Console.WriteLine(html);
9396
> [!NOTE]
9497
> Pass <xref:Microsoft.AspNetCore.Components.ParameterView.Empty?displayProperty=nameWithType> to <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A> when rendering the component without passing parameters.
9598
99+
Any calls to <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A> must be made in the context of calling `InvokeAsync` on a component dispatcher. A component dispatcher is available from the <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.Dispatcher?displayProperty=nameWithType> property.
100+
96101
Alternatively, you can write the HTML to a <xref:System.IO.TextWriter> by calling `output.WriteHtmlTo(textWriter)`.
97102

98103
The task returned by <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A> completes when the component is fully rendered, including completing any asynchronous lifecycle methods. If you want to observe the rendered HTML earlier, call <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.BeginRenderingComponent%2A> instead. Then, wait for the component rendering to complete by awaiting <xref:Microsoft.AspNetCore.Components.Web.HtmlRendering.HtmlRootComponent.QuiescenceTask%2A?displayProperty=nameWithType> on the returned <xref:Microsoft.AspNetCore.Components.Web.HtmlRendering.HtmlRootComponent> instance.

aspnetcore/blazor/fundamentals/signalr.md

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,78 @@ If reconnection fails, the user is instructed to retry or reload the page:
519519

520520
If reconnection succeeds, user state is often lost. Custom code can be added to any component to save and reload user state across connection failures. For more information, see <xref:blazor/state-management>.
521521

522-
:::moniker range=">= aspnetcore-8.0"
522+
:::moniker range=">= aspnetcore-10.0"
523+
524+
To create UI elements that track reconnection state, the following table describes:
525+
526+
* A set of `components-reconnect-*` CSS classes (**Css class** column) that are set or unset by Blazor on an element with an `id` of `components-reconnect-modal`.
527+
* A `components-reconnect-state-changed` event (**Event** column) that indicates a reconnection status change.
528+
529+
| CSS class | Event | Indicates&hellip; |
530+
| --- | --- | --- |
531+
| `components-reconnect-show` | `show` | A lost connection. The client is attempting to reconnect. The reconnection modal is shown. |
532+
| `components-reconnect-hide` | `hide` | An active connection is re-established to the server. The reconnection model is closed. |
533+
| `components-reconnect-retrying` | `retrying` | The client is attempting to reconnect. |
534+
| `components-reconnect-failed` | `failed` | Reconnection failed, probably due to a network failure. |
535+
| `components-reconnect-rejected` | `rejected` | Reconnection rejected. |
536+
537+
When the reconnection state change in `components-reconnect-state-changed` is `failed`, call `Blazor.reconnect()` in JavaScript to attempt reconnection.
538+
539+
When the reconnection state change is `rejected`, the server was reached but refused the connection, and the user's state on the server is lost. To reload the app, call `location.reload()` in JavaScript. This connection state may result when:
540+
541+
* A crash in the server-side circuit occurs.
542+
* The client is disconnected long enough for the server to drop the user's state. Instances of the user's components are disposed.
543+
* The server is restarted, or the app's worker process is recycled.
544+
545+
The developer adds an event listener on the reconnect modal element to monitor and react to reconnection state changes, as seen in the following example:
546+
547+
```javascript
548+
const reconnectModal = document.getElementById("components-reconnect-modal");
549+
reconnectModal.addEventListener("components-reconnect-state-changed",
550+
handleReconnectStateChanged);
551+
552+
function handleReconnectStateChanged(event) {
553+
if (event.detail.state === "show") {
554+
reconnectModal.showModal();
555+
} else if (event.detail.state === "hide") {
556+
reconnectModal.close();
557+
} else if (event.detail.state === "failed") {
558+
Blazor.reconnect();
559+
} else if (event.detail.state === "rejected") {
560+
location.reload();
561+
}
562+
}
563+
```
564+
565+
An element with an `id` of `components-reconnect-max-retries` displays the maximum number of reconnect retries:
566+
567+
```html
568+
<span id="components-reconnect-max-retries"></span>
569+
```
570+
571+
An element with an `id` of `components-reconnect-current-attempt` displays the current reconnect attempt:
572+
573+
```html
574+
<span id="components-reconnect-current-attempt"></span>
575+
```
576+
577+
An element with an `id` of `components-seconds-to-next-attempt` displays the number of seconds to the next reconnection attempt:
578+
579+
```html
580+
<span id="components-seconds-to-next-attempt"></span>
581+
```
582+
583+
The Blazor Web App project template includes a `ReconnectModal` component (`Components/Layout/ReconnectModal.razor`) with collocated stylesheet and JavaScript files (`ReconnectModal.razor.css`, `ReconnectModal.razor.js`) that can be customized as needed. These files can be examined in the ASP.NET Core reference source or by inspecting an app created from the Blazor Web App project template. The component is added to the project when the project is created in Visual Studio with **Interactive render mode** set to **Server** or **Auto** or created with the .NET CLI with the option `--interactivity server` (default) or `--interactivity auto`.
584+
585+
* [`ReconnectModal` component](https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Layout/ReconnectModal.razor)
586+
* [Stylesheet file](https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Layout/ReconnectModal.razor.css)
587+
* [JavaScript file](https://github.com/dotnet/aspnetcore/blob/main/src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWeb-CSharp/Components/Layout/ReconnectModal.razor.js)
588+
589+
[!INCLUDE[](~/includes/aspnetcore-repo-ref-source-links.md)]
590+
591+
:::moniker-end
592+
593+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
523594

524595
To customize the UI, define a single element with an `id` of `components-reconnect-modal` in the `<body>` element content. The following example places the element in the `App` component.
525596

@@ -551,6 +622,8 @@ To customize the UI, define a single element with an `id` of `components-reconne
551622

552623
:::moniker-end
553624

625+
:::moniker range="< aspnetcore-10.0"
626+
554627
```cshtml
555628
<div id="components-reconnect-modal">
556629
Connection lost.<br>Attempting to reconnect...
@@ -562,7 +635,9 @@ To customize the UI, define a single element with an `id` of `components-reconne
562635
563636
Add the following CSS styles to the site's stylesheet.
564637

565-
:::moniker range=">= aspnetcore-8.0"
638+
:::moniker-end
639+
640+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
566641

567642
`wwwroot/app.css`:
568643

@@ -574,6 +649,8 @@ Add the following CSS styles to the site's stylesheet.
574649

575650
:::moniker-end
576651

652+
:::moniker range="< aspnetcore-10.0"
653+
577654
```css
578655
#components-reconnect-modal {
579656
display: none;
@@ -604,13 +681,15 @@ The following table describes the CSS classes applied to the `components-reconne
604681
| `components-reconnect-failed` | Reconnection failed, probably due to a network failure. To attempt reconnection, call `window.Blazor.reconnect()` in JavaScript. |
605682
| `components-reconnect-rejected` | Reconnection rejected. The server was reached but refused the connection, and the user's state on the server is lost. To reload the app, call `location.reload()` in JavaScript. This connection state may result when:<ul><li>A crash in the server-side circuit occurs.</li><li>The client is disconnected long enough for the server to drop the user's state. Instances of the user's components are disposed.</li><li>The server is restarted, or the app's worker process is recycled.</li></ul> |
606683

607-
:::moniker range=">= aspnetcore-5.0"
684+
:::moniker-end
685+
686+
:::moniker range=">= aspnetcore-5.0 < aspnetcore-10.0"
608687

609688
Customize the delay before the reconnection UI appears by setting the `transition-delay` property in the site's CSS for the modal element. The following example sets the transition delay from 500 ms (default) to 1,000 ms (1 second).
610689

611690
:::moniker-end
612691

613-
:::moniker range=">= aspnetcore-8.0"
692+
:::moniker range=">= aspnetcore-8.0 < aspnetcore-10.0"
614693

615694
`wwwroot/app.css`:
616695

@@ -622,7 +701,7 @@ Customize the delay before the reconnection UI appears by setting the `transitio
622701

623702
:::moniker-end
624703

625-
:::moniker range=">= aspnetcore-5.0"
704+
:::moniker range=">= aspnetcore-5.0 < aspnetcore-10.0"
626705

627706
```css
628707
#components-reconnect-modal {

aspnetcore/blazor/security/includes/troubleshoot-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
9191
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
9292

9393
> [!NOTE]
94-
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org) or [FuGet Package Explorer](https://www.fuget.org).
94+
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org).
9595
9696
### Run the server app
9797

aspnetcore/blazor/security/includes/troubleshoot-wasm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
9191
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
9292

9393
> [!NOTE]
94-
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org) or [FuGet Package Explorer](https://www.fuget.org).
94+
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org).
9595
9696
:::moniker range="< aspnetcore-8.0"
9797

aspnetcore/blazor/security/webassembly/standalone-with-identity/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
361361
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
362362

363363
> [!NOTE]
364-
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org) or [FuGet Package Explorer](https://www.fuget.org).
364+
> Use of package versions incompatible with the app's target framework isn't supported. For information on a package, use the [NuGet Gallery](https://www.nuget.org).
365365
366366
### Inspect the user's claims
367367

aspnetcore/fundamentals/openapi/aspnetcore-openapi.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,14 @@ Create a new ASP.NET Core Web API (Native AOT) project.
259259
dotnet new webapiaot
260260
```
261261

262+
:::moniker-end
263+
264+
:::moniker range="= aspnetcore-9.0"
265+
262266
Add the Microsoft.AspNetCore.OpenAPI package.
263267

264268
```console
265-
dotnet add package Microsoft.AspNetCore.OpenApi --prerelease
269+
dotnet add package Microsoft.AspNetCore.OpenApi
266270
```
267271

268272
Update `Program.cs` to enable generating OpenAPI documents.
@@ -275,12 +279,12 @@ var app = builder.Build();
275279
+ app.MapOpenApi();
276280
```
277281

282+
:::moniker-end
283+
278284
Publish the app.
279285

280286
```console
281287
dotnet publish
282288
```
283289

284-
:::moniker-end
285-
286290
[!INCLUDE[](~/fundamentals/openapi/includes/aspnetcore-openapi6-8.md)]

aspnetcore/host-and-deploy/iis/advanced.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Advanced configuration with the ASP.NET Core Module and Internet In
55
monikerRange: '>= aspnetcore-5.0'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 10/09/2023
8+
ms.date: 03/07/2025
99
uid: host-and-deploy/iis/advanced
1010
---
1111
# Advanced configuration of the ASP.NET Core Module and IIS
@@ -18,7 +18,8 @@ This article covers advanced configuration options and scenarios for the ASP.NET
1818

1919
*Only applies when using the in-process hosting model.*
2020

21-
Configure the managed stack size using the `stackSize` setting in bytes in the `web.config` file. The default size is 1,048,576 bytes (1 MB). The following example changes the stack size to 2 MB (2,097,152 bytes):
21+
:::moniker range="> aspnetcore-9.0"
22+
Configure the managed stack size using the `stackSize` setting in bytes in hexadecimal in the `web.config` file. The default size is 1,048,576 bytes (1 MB) expressed in hexadecimal. The following example changes the stack size to 2 MB (2,097,152 bytes) in hexadecimal 0x200000:
2223

2324
```xml
2425
<aspNetCore processPath="dotnet"
@@ -27,11 +28,31 @@ Configure the managed stack size using the `stackSize` setting in bytes in the `
2728
stdoutLogFile="\\?\%home%\LogFiles\stdout"
2829
hostingModel="inprocess">
2930
<handlerSettings>
30-
<handlerSetting name="stackSize" value="2097152" />
31+
<handlerSetting name="stackSize" value="200000" />
3132
</handlerSettings>
3233
</aspNetCore>
3334
```
3435

36+
:::moniker-end
37+
38+
:::moniker range="<= aspnetcore-9.0"
39+
40+
Configure the managed stack size using the `stackSize` setting in bytes in the `web.config` file. The default size is 17,825,792 bytes (17 MB). The following example changes the stack size to 100,000 hex, (1 MB):
41+
42+
```xml
43+
<aspNetCore processPath="dotnet"
44+
arguments=".\MyApp.dll"
45+
stdoutLogEnabled="false"
46+
stdoutLogFile="\\?\%home%\LogFiles\stdout"
47+
hostingModel="inprocess">
48+
<handlerSettings>
49+
<handlerSetting name="stackSize" value="100000" />
50+
</handlerSettings>
51+
</aspNetCore>
52+
```
53+
54+
:::moniker-end
55+
3556
## Disallow rotation on config
3657

3758
The `disallowRotationOnConfigChange` setting is intended for blue/green scenarios where a change to global config should not cause all sites to recycle. When this flag is true, only changes relevant to the site itself will cause it to recycle. For example, a site recycles if its *web.config* changes or something changes that is relevant to the site's path from IIS's perspective. But a general change to *applicationHost.config* would not cause an app to recycle. The following example sets this setting to true:

aspnetcore/introduction-to-aspnet-core.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ASP.NET Core is a cross-platform, high-performance, [open-source](https://github
1919

2020
With ASP.NET Core, you can:
2121

22-
* Build web apps and services, [Internet of Things (IoT)](https://www.microsoft.com/internet-of-things/) apps, and mobile backends.
22+
* Build web apps and services, [Azure IoT (Internet of Things)](https://azure.microsoft.com/solutions/iot) apps, and mobile backends.
2323
* Use your favorite development tools on Windows, macOS, and Linux.
2424
* Deploy to the cloud or on-premises.
2525
* Run on [.NET](/dotnet/core/introduction).
@@ -98,7 +98,7 @@ For a reference guide to migrating ASP.NET 4.x apps to ASP.NET Core, see <xref:m
9898

9999
ASP.NET Core is a cross-platform, high-performance, [open-source](https://github.com/dotnet/aspnetcore) framework for building modern, cloud-enabled, Internet-connected apps. With ASP.NET Core, you can:
100100

101-
* Build web apps and services, [Internet of Things (IoT)](https://www.microsoft.com/internet-of-things/) apps, and mobile backends.
101+
* Build web apps and services, [Azure IoT (Internet of Things)](https://azure.microsoft.com/solutions/iot) apps, and mobile backends.
102102
* Use your favorite development tools on Windows, macOS, and Linux.
103103
* Deploy to the cloud or on-premises.
104104
* Run on [.NET Core or .NET Framework](/dotnet/articles/standard/choosing-core-framework-server).

aspnetcore/performance/rate-limit.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
22
title: Rate limiting middleware in ASP.NET Core
3-
author: tdykstra
3+
author: rick-anderson
4+
ms.author: riande
45
monikerRange: '>= aspnetcore-7.0'
56
description: Learn how limit requests in ASP.NET Core apps
6-
ms.author: tdykstra
77
ms.custom: mvc
8-
ms.date: 10/29/2022
8+
ms.date: 03/05/2025
99
uid: performance/rate-limit
1010
---
1111

@@ -44,7 +44,7 @@ The preceding code:
4444
* Calls `AddFixedWindowLimiter` to create a fixed window limiter with a policy name of `"fixed"` and sets:
4545
* <xref:System.Threading.RateLimiting.FixedWindowRateLimiterOptions.PermitLimit> to 4 and the time <xref:System.Threading.RateLimiting.FixedWindowRateLimiterOptions.Window> to 12. A maximum of 4 requests per each 12-second window are allowed.
4646
* <xref:System.Threading.RateLimiting.FixedWindowRateLimiterOptions.QueueProcessingOrder> to <xref:System.Threading.RateLimiting.QueueProcessingOrder.OldestFirst>.
47-
* <xref:System.Threading.RateLimiting.FixedWindowRateLimiterOptions.QueueLimit> to 2.
47+
* <xref:System.Threading.RateLimiting.FixedWindowRateLimiterOptions.QueueLimit> to 2 (set this to 0 to disable the queueing mechanism).
4848
* Calls [UseRateLimiter](/dotnet/api/microsoft.aspnetcore.builder.ratelimiterapplicationbuilderextensions.useratelimiter) to enable rate limiting.
4949

5050
Apps should use [Configuration](xref:fundamentals/configuration/index) to set limiter options. The following code updates the preceding code using [`MyRateLimitOptions`](https://github.com/dotnet/AspNetCore.Docs.Samples/blob/main/fundamentals/middleware/rate-limit/WebRateLimitAuth/Models/MyRateLimitOptions.cs) for configuration:
@@ -140,7 +140,7 @@ The <xref:System.Threading.RateLimiting.PartitionedRateLimiter.CreateChained%2A>
140140

141141
The following code uses `CreateChained`:
142142

143-
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/rate-limit/WebRate2/Program.cs" id="snippet_3" highlight="21,51":::
143+
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/rate-limit/WebRate2/Program.cs" id="snippet_3" highlight="19,20,33":::
144144

145145
For more information, see the [CreateChained source code](https://github.com/dotnet/runtime/blob/79874806d246670ee5fe76e73ce566578fe675c0/src/libraries/System.Threading.RateLimiting/src/System/Threading/RateLimiting/PartitionedRateLimiter.cs#L52-L64)
146146

0 commit comments

Comments
 (0)