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
Copy file name to clipboardExpand all lines: aspnetcore/blazor/components/integration.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
@@ -418,7 +418,7 @@ In `Pages/_Host.cshtml` of Blazor apps that are `ServerPrerendered` in a Blazor
418
418
419
419
:::moniker range=">= aspnetcore-10.0"
420
420
421
-
Decide what state to persist using the <xref:Microsoft.AspNetCore.Components.PersistentComponentState> service. The [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) applied to a property registers a callback to persist the state during prerendering and loads it when the component renders interactively or the service is instantiated.
421
+
Decide what state to persist using the <xref:Microsoft.AspNetCore.Components.PersistentComponentState> service. The [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) applied to a `public`property registers a callback to persist the state during prerendering and loads it when the component renders interactively or the service is instantiated.
422
422
423
423
In the following example, the `{TYPE}` placeholder represents the type of data to persist (for example, `WeatherForecast[]`).
Copy file name to clipboardExpand all lines: aspnetcore/blazor/forms/index.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
@@ -69,7 +69,7 @@ Standard HTML forms are supported. Create a form using the normal HTML `<form>`
69
69
In the preceding `StarshipPlainForm` component:
70
70
71
71
* The form is rendered where the `<form>` element appears. The form is named with the [`@formname`](xref:mvc/views/razor#formname) directive attribute, which uniquely identifies the form to the Blazor framework.
72
-
* The model is created in the component's `@code` block and held in a public property (`Model`). The `[SupplyParameterFromForm]` attribute indicates that the value of the associated property should be supplied from the form data. Data in the request that matches the property's name is bound to the property.
72
+
* The model is created in the component's `@code` block and held in a `public` property (`Model`). The `[SupplyParameterFromForm]` attribute indicates that the value of the associated property should be supplied from the form data. Data in the request that matches the property's name is bound to the property.
73
73
* The <xref:Microsoft.AspNetCore.Components.Forms.InputText> component is an input component for editing string values. The `@bind-Value` directive attribute binds the `Model.Id` model property to the <xref:Microsoft.AspNetCore.Components.Forms.InputText> component's <xref:Microsoft.AspNetCore.Components.Forms.InputBase%601.Value%2A> property.
74
74
* The `Submit` method is registered as a handler for the <!-- <xref:Microsoft.AspNetCore.Components.Forms.EditForm.OnSubmit> -->`@onsubmit` callback. The handler is called when the form is submitted by the user.
75
75
@@ -117,7 +117,7 @@ A form is defined using the Blazor framework's <xref:Microsoft.AspNetCore.Compon
117
117
In the preceding `Starship1` component:
118
118
119
119
* The <xref:Microsoft.AspNetCore.Components.Forms.EditForm> component is rendered where the `<EditForm>` element appears. The form is named with the <xref:Microsoft.AspNetCore.Components.Forms.EditForm.FormName> property, which uniquely identifies the form to the Blazor framework.
120
-
* The model is created in the component's `@code` block and held in a public property (`Model`). The property is assigned to the <xref:Microsoft.AspNetCore.Components.Forms.EditForm.Model?displayProperty=nameWithType> parameter. The `[SupplyParameterFromForm]` attribute indicates that the value of the associated property should be supplied from the form data. Data in the request that matches the property's name is bound to the property.
120
+
* The model is created in the component's `@code` block and held in a `public` property (`Model`). The property is assigned to the <xref:Microsoft.AspNetCore.Components.Forms.EditForm.Model?displayProperty=nameWithType> parameter. The `[SupplyParameterFromForm]` attribute indicates that the value of the associated property should be supplied from the form data. Data in the request that matches the property's name is bound to the property.
121
121
* The <xref:Microsoft.AspNetCore.Components.Forms.InputText> component is an [input component](xref:blazor/forms/input-components) for editing string values. The `@bind-Value` directive attribute binds the `Model.Id` model property to the <xref:Microsoft.AspNetCore.Components.Forms.InputText> component's <xref:Microsoft.AspNetCore.Components.Forms.InputBase%601.Value%2A> property.
122
122
* The `Submit` method is registered as a handler for the <xref:Microsoft.AspNetCore.Components.Forms.EditForm.OnSubmit> callback. The handler is called when the form is submitted by the user.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/state-management/prerendered-state-persistence.md
+6-4Lines changed: 6 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,13 +38,15 @@ The persisted prerendered state is transferred to the client, where it's used to
38
38
39
39
:::moniker range=">= aspnetcore-10.0"
40
40
41
-
To preserve prerendered state, use the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) to persist state in properties. Properties with this attribute are automatically persisted using the <xref:Microsoft.AspNetCore.Components.PersistentComponentState> service during prerendering. The state is retrieved when the component renders interactively or the service is instantiated.
41
+
To persist prerendered state using the <xref:Microsoft.AspNetCore.Components.PersistentComponentState> service, apply the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) to `public` properties. The state is retrieved when the component renders interactively or the <xref:Microsoft.AspNetCore.Components.PersistentComponentState> service is instantiated.
42
+
43
+
Use `public` properties because reflection is used by the framework for tasks such as [trimming unused code](xref:blazor/performance/app-download-size#intermediate-language-il-trimming) and [source generation](/dotnet/csharp/roslyn-sdk/source-generators-overview).
42
44
43
45
By default, properties are serialized using the <xref:System.Text.Json?displayProperty=fullName> serializer with default settings and persisted in the prerendered HTML. Serialization isn't trimmer safe and requires preservation of the types used. For more information, see <xref:blazor/host-and-deploy/configure-trimmer>.
44
46
45
47
The following counter component persists counter state during prerendering and retrieves the state to initialize the component:
46
48
47
-
* The [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) is applied to the nullable `int`type (`CurrentCount`).
49
+
* The [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) is applied to the public nullable `CurrentCount` property of type `int?`.
48
50
* The counter's state is assigned when `null` in `OnInitialized` and restored automatically when the component renders interactively.
49
51
50
52
`PrerenderedCounter2.razor`:
@@ -94,7 +96,7 @@ When the component executes, `CurrentCount` is only set once during prerendering
94
96
95
97
In the following example that serializes state for multiple components of the same type:
96
98
97
-
*Properties annotated with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) are serialized during prerendering.
99
+
*Public properties annotated with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) are serialized during prerendering.
98
100
* The [`@key` directive attribute](xref:blazor/components/key#use-of-the-key-directive-attribute) is used to ensure that the state is correctly associated with the component instance.
99
101
* The `Element` property is initialized in the [`OnInitialized` lifecycle method](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) to avoid null reference exceptions, similarly to how null references are avoided for query parameters and form data.
100
102
@@ -159,7 +161,7 @@ Serialized properties are identified from the actual service instance:
159
161
* Supports shared code in different assemblies.
160
162
* Results in each instance exposing the same properties.
161
163
162
-
The following counter service, `CounterTracker`, marks its current count property, `CurrentCount` with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute). The property is serialized during prerendering and deserialized when the app becomes interactive wherever the service is injected.
164
+
The following counter service, `CounterTracker`, marks its current count property, `CurrentCount` with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute). The public property is serialized during prerendering and deserialized when the app becomes interactive wherever the service is injected.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/state-management/server.md
+6-2Lines changed: 6 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ Persisting component state across circuits is built on top of the existing <xref
100
100
> [NOTE]
101
101
> Persisting component state for prerendering works for any interactive render mode, but circuit state persistence only works for the **Interactive Server** render mode.
102
102
103
-
Annotate component properties with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) to enable circuit state persistence. The following example also keys the items with the [`@key` directive attribute](xref:blazor/components/key) to provide a unique identifier for each component instance:
103
+
Annotate component `public`properties with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute) to enable circuit state persistence. The following example also keys the items with the [`@key` directive attribute](xref:blazor/components/key) to provide a unique identifier for each component instance:
104
104
105
105
```razor
106
106
@foreach (var item in Items)
@@ -119,7 +119,11 @@ Annotate component properties with the [`[PersistentState]` attribute](xref:Micr
119
119
}
120
120
```
121
121
122
-
To persist state for scoped services, annotate service properties with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute), add the service to the service collection, and call the <xref:Microsoft.Extensions.DependencyInjection.RazorComponentsRazorComponentBuilderExtensions.RegisterPersistentService%2A> extension method with the service:
122
+
To persist state for a scoped service:
123
+
124
+
* Annotate the `public` service property with the [`[PersistentState]` attribute](xref:Microsoft.AspNetCore.Components.PersistentStateAttribute).
125
+
* Add the service to the service collection.
126
+
* Call the <xref:Microsoft.Extensions.DependencyInjection.RazorComponentsRazorComponentBuilderExtensions.RegisterPersistentService%2A> extension method with the service.
Copy file name to clipboardExpand all lines: aspnetcore/blazor/tutorials/movie-database-app/part-5.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
@@ -19,7 +19,7 @@ This part of the tutorial series explains how metadata of the `Movie` model is u
19
19
20
20
## Validation using data annotations
21
21
22
-
Validation rules are specified on a model class using *data annotations*. The following list shows some of the <xref:System.ComponentModel.DataAnnotations> attributes for user input validation of public properties in a form's model:
22
+
Validation rules are specified on a model class using *data annotations*. The following list shows some of the <xref:System.ComponentModel.DataAnnotations> attributes for user input validation of `public` properties in a form's model:
23
23
24
24
*[`[Required]`](xref:System.ComponentModel.DataAnnotations.RequiredAttribute): Require that the user provide a value.
25
25
*[`[StringLength]`](xref:System.ComponentModel.DataAnnotations.StringLengthAttribute): Specifies the minimum and maximum length of characters. Note that a `MinimumLength` passed to the attribute doesn't make the string required (apply the [`[Required]` attribute](xref:System.ComponentModel.DataAnnotations.RequiredAttribute)).
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg006.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
@@ -26,7 +26,7 @@ This diagnostic is emitted by the [Request Delegate Generator](/aspnet/core/fund
26
26
27
27
### Rule description
28
28
29
-
Types that are used for surrogate binding via the [`[AsParameters]`](xref:Microsoft.AspNetCore.Http.AsParametersAttribute) attribute must contain a public parameterized constructor where all parameters to the constructor match the public properties declared on the type. The `TodoRequest` type produces this diagnostic because there is no matching constructor parameter for the `Todo` property.
29
+
Types that are used for surrogate binding via the [`[AsParameters]`](xref:Microsoft.AspNetCore.Http.AsParametersAttribute) attribute must contain a `public` parameterized constructor where all parameters to the constructor match the `public` properties declared on the type. The `TodoRequest` type produces this diagnostic because there is no matching constructor parameter for the `Todo` property.
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/http-requests.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -469,7 +469,7 @@ A typed client accepts an `HttpClient` parameter in its constructor:
469
469
In the preceding code:
470
470
471
471
* The configuration is moved into the typed client.
472
-
* The `HttpClient` object is exposed as a public property.
472
+
* The `HttpClient` object is exposed as a `public` property.
473
473
474
474
<!--
475
475
The preceding code can be written as:
@@ -894,7 +894,7 @@ A typed client accepts an `HttpClient` parameter in its constructor:
894
894
In the preceding code:
895
895
896
896
* The configuration is moved into the typed client.
897
-
* The `HttpClient` object is exposed as a public property.
897
+
* The `HttpClient` object is exposed as a `public` property.
898
898
899
899
API-specific methods can be created that expose `HttpClient` functionality. For example, the `GetAspNetDocsIssues` method encapsulates code to retrieve open issues.
900
900
@@ -1299,7 +1299,7 @@ A typed client accepts an `HttpClient` parameter in its constructor:
In the preceding code, the configuration is moved into the typed client. The `HttpClient` object is exposed as a public property. It's possible to define API-specific methods that expose `HttpClient` functionality. The `GetAspNetDocsIssues` method encapsulates the code needed to query for and parse out the latest open issues from a GitHub repository.
1302
+
In the preceding code, the configuration is moved into the typed client. The `HttpClient` object is exposed as a `public` property. It's possible to define API-specific methods that expose `HttpClient` functionality. The `GetAspNetDocsIssues` method encapsulates the code needed to query for and parse out the latest open issues from a GitHub repository.
1303
1303
1304
1304
To register a typed client, the generic <xref:Microsoft.Extensions.DependencyInjection.HttpClientFactoryServiceCollectionExtensions.AddHttpClient%2A> extension method can be used within `Startup.ConfigureServices`, specifying the typed client class:
0 commit comments