You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following example, a Razor component is rendered to an HTML string from a console app:
18
18
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:
20
20
21
21
```dotnetcli
22
22
dotnet new console -o ConsoleApp1
23
23
cd ConsoleApp1
24
24
```
25
25
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>:
Add a package reference for <xref:Microsoft.Extensions.Logging?displayProperty=fullName>:
33
+
34
+
```dotnetcli
30
35
dotnet add package Microsoft.Extensions.Logging
31
36
```
32
37
@@ -48,17 +53,15 @@ Add the following `RenderMessage` component to the project.
48
53
49
54
@code {
50
55
[Parameter]
51
-
public string Message { get; set; }
56
+
public string? Message { get; set; }
52
57
}
53
58
```
54
59
55
-
Update the `Program` file:
60
+
Replace the code in the `Program` file with the following code:
56
61
57
62
* 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>).
58
63
* Create an <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer> and render the `RenderMessage` component by calling <xref:Microsoft.AspNetCore.Components.Web.HtmlRenderer.RenderComponentAsync%2A>.
59
64
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
-
62
65
```csharp
63
66
usingMicrosoft.AspNetCore.Components;
64
67
usingMicrosoft.AspNetCore.Components.Web;
@@ -93,6 +96,8 @@ Console.WriteLine(html);
93
96
> [!NOTE]
94
97
> 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.
95
98
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
+
96
101
Alternatively, you can write the HTML to a <xref:System.IO.TextWriter> by calling `output.WriteHtmlTo(textWriter)`.
97
102
98
103
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.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/fundamentals/signalr.md
+84-5Lines changed: 84 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -519,7 +519,78 @@ If reconnection fails, the user is instructed to retry or reload the page:
519
519
520
520
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>.
521
521
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…|
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. |
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:
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`.
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.
525
596
@@ -551,6 +622,8 @@ To customize the UI, define a single element with an `id` of `components-reconne
551
622
552
623
:::moniker-end
553
624
625
+
:::moniker range="< aspnetcore-10.0"
626
+
554
627
```cshtml
555
628
<div id="components-reconnect-modal">
556
629
Connection lost.<br>Attempting to reconnect...
@@ -562,7 +635,9 @@ To customize the UI, define a single element with an `id` of `components-reconne
562
635
563
636
Add the following CSS styles to the site's stylesheet.
@@ -574,6 +649,8 @@ Add the following CSS styles to the site's stylesheet.
574
649
575
650
:::moniker-end
576
651
652
+
:::moniker range="< aspnetcore-10.0"
653
+
577
654
```css
578
655
#components-reconnect-modal {
579
656
display: none;
@@ -604,13 +681,15 @@ The following table describes the CSS classes applied to the `components-reconne
604
681
|`components-reconnect-failed`| Reconnection failed, probably due to a network failure. To attempt reconnection, call `window.Blazor.reconnect()` in JavaScript. |
605
682
|`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> |
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).
Copy file name to clipboardExpand all lines: aspnetcore/blazor/security/includes/troubleshoot-server.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
91
91
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
92
92
93
93
> [!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).
Copy file name to clipboardExpand all lines: aspnetcore/blazor/security/includes/troubleshoot-wasm.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
91
91
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
92
92
93
93
> [!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).
Copy file name to clipboardExpand all lines: aspnetcore/blazor/security/webassembly/standalone-with-identity/index.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -361,7 +361,7 @@ A functioning app may fail immediately after upgrading either the .NET Core SDK
361
361
1. Delete all of the files in the deployment folder on the server prior to redeploying the app.
362
362
363
363
> [!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).
Copy file name to clipboardExpand all lines: aspnetcore/host-and-deploy/iis/advanced.md
+24-3Lines changed: 24 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Advanced configuration with the ASP.NET Core Module and Internet In
5
5
monikerRange: '>= aspnetcore-5.0'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 10/09/2023
8
+
ms.date: 03/07/2025
9
9
uid: host-and-deploy/iis/advanced
10
10
---
11
11
# 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
18
18
19
19
*Only applies when using the in-process hosting model.*
20
20
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:
22
23
23
24
```xml
24
25
<aspNetCoreprocessPath="dotnet"
@@ -27,11 +28,31 @@ Configure the managed stack size using the `stackSize` setting in bytes in the `
27
28
stdoutLogFile="\\?\%home%\LogFiles\stdout"
28
29
hostingModel="inprocess">
29
30
<handlerSettings>
30
-
<handlerSettingname="stackSize"value="2097152" />
31
+
<handlerSettingname="stackSize"value="200000" />
31
32
</handlerSettings>
32
33
</aspNetCore>
33
34
```
34
35
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
+
<aspNetCoreprocessPath="dotnet"
44
+
arguments=".\MyApp.dll"
45
+
stdoutLogEnabled="false"
46
+
stdoutLogFile="\\?\%home%\LogFiles\stdout"
47
+
hostingModel="inprocess">
48
+
<handlerSettings>
49
+
<handlerSettingname="stackSize"value="100000" />
50
+
</handlerSettings>
51
+
</aspNetCore>
52
+
```
53
+
54
+
:::moniker-end
55
+
35
56
## Disallow rotation on config
36
57
37
58
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:
Copy file name to clipboardExpand all lines: aspnetcore/introduction-to-aspnet-core.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ ASP.NET Core is a cross-platform, high-performance, [open-source](https://github
19
19
20
20
With ASP.NET Core, you can:
21
21
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.
23
23
* Use your favorite development tools on Windows, macOS, and Linux.
24
24
* Deploy to the cloud or on-premises.
25
25
* 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
98
98
99
99
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:
100
100
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.
102
102
* Use your favorite development tools on Windows, macOS, and Linux.
103
103
* Deploy to the cloud or on-premises.
104
104
* Run on [.NET Core or .NET Framework](/dotnet/articles/standard/choosing-core-framework-server).
Copy file name to clipboardExpand all lines: aspnetcore/performance/rate-limit.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
---
2
2
title: Rate limiting middleware in ASP.NET Core
3
-
author: tdykstra
3
+
author: rick-anderson
4
+
ms.author: riande
4
5
monikerRange: '>= aspnetcore-7.0'
5
6
description: Learn how limit requests in ASP.NET Core apps
6
-
ms.author: tdykstra
7
7
ms.custom: mvc
8
-
ms.date: 10/29/2022
8
+
ms.date: 03/05/2025
9
9
uid: performance/rate-limit
10
10
---
11
11
@@ -44,7 +44,7 @@ The preceding code:
44
44
* Calls `AddFixedWindowLimiter` to create a fixed window limiter with a policy name of `"fixed"` and sets:
45
45
*<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.
46
46
*<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).
48
48
* Calls [UseRateLimiter](/dotnet/api/microsoft.aspnetcore.builder.ratelimiterapplicationbuilderextensions.useratelimiter) to enable rate limiting.
49
49
50
50
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>
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)
0 commit comments