Skip to content

Commit cfba7b7

Browse files
authored
Merge pull request #17911 from dotnet/master
2 parents 3d07e21 + bb89d53 commit cfba7b7

12 files changed

Lines changed: 42 additions & 23 deletions

File tree

aspnetcore/blazor/call-web-api.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to call a web API from a Blazor WebAssembly app using JSO
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 04/16/2020
8+
ms.date: 04/19/2020
99
no-loc: [Blazor, SignalR]
1010
uid: blazor/call-web-api
1111
---
@@ -112,7 +112,11 @@ JSON helper methods send requests to a URI (a web API in the following examples)
112112
}
113113
```
114114

115-
Calls to `PostAsJsonAsync` return an <xref:System.Net.Http.HttpResponseMessage>.
115+
Calls to `PostAsJsonAsync` return an <xref:System.Net.Http.HttpResponseMessage>. To deserialize the JSON content from the response message, use the `ReadFromJsonAsync<T>` extension method:
116+
117+
```csharp
118+
var content = response.content.ReadFromJsonAsync<WeatherForecast>();
119+
```
116120

117121
* `PutAsJsonAsync` &ndash; Sends an HTTP PUT request, including JSON-encoded content.
118122

@@ -141,7 +145,11 @@ JSON helper methods send requests to a URI (a web API in the following examples)
141145
}
142146
```
143147

144-
Calls to `PutAsJsonAsync` return an <xref:System.Net.Http.HttpResponseMessage>.
148+
Calls to `PutAsJsonAsync` return an <xref:System.Net.Http.HttpResponseMessage>. To deserialize the JSON content from the response message, use the `ReadFromJsonAsync<T>` extension method:
149+
150+
```csharp
151+
var content = response.content.ReadFromJsonAsync<WeatherForecast>();
152+
```
145153

146154
<xref:System.Net.Http> includes additional extension methods for sending HTTP requests and receiving HTTP responses. [HttpClient.DeleteAsync](xref:System.Net.Http.HttpClient.DeleteAsync*) is used to send an HTTP DELETE request to a web API.
147155

aspnetcore/blazor/templates.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn about ASP.NET Core Blazor app templates and Blazor project st
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 03/26/2020
8+
ms.date: 04/19/2020
99
no-loc: [Blazor, SignalR]
1010
uid: blazor/templates
1111
---
@@ -24,6 +24,13 @@ For more information on Blazor's hosting models, see <xref:blazor/hosting-models
2424

2525
For step-by-step instructions on creating a Blazor app from a template, see <xref:blazor/get-started>.
2626

27+
Template options are available by passing the `--help` option to the [dotnet new](/dotnet/core/tools/dotnet-new) CLI command:
28+
29+
```dotnetcli
30+
dotnet new blazorwasm --help
31+
dotnet new blazorserver --help
32+
```
33+
2734
## Blazor project structure
2835

2936
The following files and folders make up a Blazor app generated from a Blazor template:

aspnetcore/data/ef-rp/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ A student can enroll in any number of courses, and a course can have any number
154154

155155
[!code-csharp[Main](intro/samples/cu30snapshots/1-intro/Models/Student.cs)]
156156

157-
The `ID` property becomes the primary key column of the database table that corresponds to this class. By default, EF Core interprets a property that's named `ID` or `classnameID` as the primary key. So the alternative automatically recognized name for the `Student` class primary key is `StudentID`.
157+
The `ID` property becomes the primary key column of the database table that corresponds to this class. By default, EF Core interprets a property that's named `ID` or `classnameID` as the primary key. So the alternative automatically recognized name for the `Student` class primary key is `StudentID`. For more information, see [EF Core - Keys](/ef/core/modeling/keys?tabs=data-annotations).
158158

159159
The `Enrollments` property is a [navigation property](/ef/core/modeling/relationships). Navigation properties hold other entities that are related to this entity. In this case, the `Enrollments` property of a `Student` entity holds all of the `Enrollment` entities that are related to that Student. For example, if a Student row in the database has two related Enrollment rows, the `Enrollments` navigation property contains those two Enrollment entities.
160160

aspnetcore/fundamentals/dependency-injection.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Transient lifetime services (<xref:Microsoft.Extensions.DependencyInjection.Serv
190190
Scoped lifetime services (<xref:Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddScoped*>) are created once per client request (connection).
191191

192192
> [!WARNING]
193-
> When using a scoped service in a middleware, inject the service into the `Invoke` or `InvokeAsync` method. Don't inject via constructor injection because it forces the service to behave like a singleton. For more information, see <xref:fundamentals/middleware/write#per-request-middleware-dependencies>.
193+
> When using a scoped service in a middleware, inject the service into the `Invoke` or `InvokeAsync` method. Don't inject via [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) because it forces the service to behave like a singleton. For more information, see <xref:fundamentals/middleware/write#per-request-middleware-dependencies>.
194194
195195
### Singleton
196196

@@ -255,9 +255,9 @@ Services can be resolved by two mechanisms:
255255

256256
Constructors can accept arguments that aren't provided by dependency injection, but the arguments must assign default values.
257257

258-
When services are resolved by `IServiceProvider` or `ActivatorUtilities`, constructor injection requires a *public* constructor.
258+
When services are resolved by `IServiceProvider` or `ActivatorUtilities`, [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) requires a *public* constructor.
259259

260-
When services are resolved by `ActivatorUtilities`, constructor injection requires that only one applicable constructor exists. Constructor overloads are supported, but only one overload can exist whose arguments can all be fulfilled by dependency injection.
260+
When services are resolved by `ActivatorUtilities`, [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) requires that only one applicable constructor exists. Constructor overloads are supported, but only one overload can exist whose arguments can all be fulfilled by dependency injection.
261261

262262
## Entity Framework contexts
263263

@@ -727,7 +727,7 @@ Transient lifetime services (<xref:Microsoft.Extensions.DependencyInjection.Serv
727727
Scoped lifetime services (<xref:Microsoft.Extensions.DependencyInjection.ServiceCollectionServiceExtensions.AddScoped*>) are created once per client request (connection).
728728

729729
> [!WARNING]
730-
> When using a scoped service in a middleware, inject the service into the `Invoke` or `InvokeAsync` method. Don't inject via constructor injection because it forces the service to behave like a singleton. For more information, see <xref:fundamentals/middleware/write#per-request-middleware-dependencies>.
730+
> When using a scoped service in a middleware, inject the service into the `Invoke` or `InvokeAsync` method. Don't inject via [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) because it forces the service to behave like a singleton. For more information, see <xref:fundamentals/middleware/write#per-request-middleware-dependencies>.
731731
732732
### Singleton
733733

@@ -792,9 +792,9 @@ Services can be resolved by two mechanisms:
792792

793793
Constructors can accept arguments that aren't provided by dependency injection, but the arguments must assign default values.
794794

795-
When services are resolved by `IServiceProvider` or `ActivatorUtilities`, constructor injection requires a *public* constructor.
795+
When services are resolved by `IServiceProvider` or `ActivatorUtilities`, [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) requires a *public* constructor.
796796

797-
When services are resolved by `ActivatorUtilities`, constructor injection requires that only one applicable constructor exists. Constructor overloads are supported, but only one overload can exist whose arguments can all be fulfilled by dependency injection.
797+
When services are resolved by `ActivatorUtilities`, [constructor injection](xref:mvc/controllers/dependency-injection#constructor-injection) requires that only one applicable constructor exists. Constructor overloads are supported, but only one overload can exist whose arguments can all be fulfilled by dependency injection.
798798

799799
## Entity Framework contexts
800800

aspnetcore/includes/RP/model1b.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Add the following properties to the `Movie` class:
66
The `Movie` class contains:
77

88
* The `ID` field is required by the database for the primary key.
9-
* `[DataType(DataType.Date)]`: The [DataType](/dotnet/api/microsoft.aspnetcore.mvc.dataannotations.internal.datatypeattributeadapter) attribute specifies the type of the data (Date). With this attribute:
9+
* `[DataType(DataType.Date)]`: The [DataType](xref:System.ComponentModel.DataAnnotations.DataTypeAttribute) attribute specifies the type of the data (Date). With this attribute:
1010

1111
* The user is not required to enter time information in the date field.
1212
* Only the date is displayed, not time information.

aspnetcore/includes/blazor-security/fetchdata-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If the request failed because the token couldn't be provisioned without user int
3838
{
3939
httpClient.DefaultRequestHeaders.Add("Authorization",
4040
$"Bearer {token.Value}");
41-
forecasts = await httpClient.GetJsonAsync<WeatherForecast[]>(
41+
forecasts = await httpClient.GetFromJsonAsync<WeatherForecast[]>(
4242
"WeatherForecast");
4343
}
4444
else

aspnetcore/includes/blazor-security/imports-hosted.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using System.Net.Http
2+
@using System.Net.Http.Json
23
@using Microsoft.AspNetCore.Components.Authorization
34
@using Microsoft.AspNetCore.Components.Forms
45
@using Microsoft.AspNetCore.Components.Routing

aspnetcore/includes/blazor-security/imports-standalone.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@using System.Net.Http
2+
@using System.Net.Http.Json
23
@using Microsoft.AspNetCore.Components.Authorization
34
@using Microsoft.AspNetCore.Components.Forms
45
@using Microsoft.AspNetCore.Components.Routing

aspnetcore/mvc/models/file-uploads.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: How to use model binding and streaming to upload files in ASP.NET C
55
monikerRange: '>= aspnetcore-2.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 02/25/2020
8+
ms.date: 04/18/2020
99
uid: mvc/models/file-uploads
1010
---
1111
# Upload files in ASP.NET Core
@@ -49,7 +49,7 @@ Security steps that reduce the likelihood of a successful attack are:
4949
>
5050
> For information on reducing the attack surface area when accepting files from users, see the following resources:
5151
>
52-
> * [Unrestricted File Upload](https://www.owasp.org/index.php/Unrestricted_File_Upload)
52+
> * [Unrestricted File Upload](https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload)
5353
> * [Azure Security: Ensure appropriate controls are in place when accepting files from users](/azure/security/azure-security-threat-modeling-tool-input-validation#controls-users)
5454
5555
For more information on implementing security measures, including examples from the sample app, see the [Validation](#validation) section.
@@ -778,7 +778,7 @@ Security steps that reduce the likelihood of a successful attack are:
778778
>
779779
> For information on reducing the attack surface area when accepting files from users, see the following resources:
780780
>
781-
> * [Unrestricted File Upload](https://www.owasp.org/index.php/Unrestricted_File_Upload)
781+
> * [Unrestricted File Upload](https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload)
782782
> * [Azure Security: Ensure appropriate controls are in place when accepting files from users](/azure/security/azure-security-threat-modeling-tool-input-validation#controls-users)
783783

784784
For more information on implementing security measures, including examples from the sample app, see the [Validation](#validation) section.
@@ -1466,6 +1466,6 @@ The examples in this topic rely upon <xref:System.IO.MemoryStream> to hold the u
14661466

14671467
## Additional resources
14681468

1469-
* [Unrestricted File Upload](https://www.owasp.org/index.php/Unrestricted_File_Upload)
1469+
* [Unrestricted File Upload](https://owasp.org/www-community/vulnerabilities/Unrestricted_File_Upload)
14701470
* [Azure Security: Security Frame: Input Validation | Mitigations](/azure/security/azure-security-threat-modeling-tool-input-validation)
14711471
* [Azure Cloud Design Patterns: Valet Key pattern](/azure/architecture/patterns/valet-key)

aspnetcore/security/blazor/webassembly/additional-scenarios.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description:
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 03/30/2020
8+
ms.date: 04/19/2020
99
no-loc: [Blazor, SignalR]
1010
uid: security/blazor/webassembly/additional-scenarios
1111
---
@@ -134,7 +134,7 @@ The following example shows how to:
134134
{
135135
httpClient.DefaultRequestHeaders.Add("Authorization",
136136
$"Bearer {token.Value}");
137-
await httpClient.PostJsonAsync("Save", User);
137+
await httpClient.PostAsJsonAsync("Save", User);
138138
}
139139
else
140140
{

0 commit comments

Comments
 (0)