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
You can set additional options using the more generic `SetBrowserRequestOption` extension method.
229
+
230
+
The HTTP response is typically buffered in a Blazor WebAssembly app to enable support for sync reads on the response content. To enable support for response streaming, use the `SetBrowserResponseStreamingEnabled` extension method on the request.
231
+
219
232
For more information on Fetch API options, see [MDN web docs: WindowOrWorkerGlobalScope.fetch():Parameters](https://developer.mozilla.org/docs/Web/API/WindowOrWorkerGlobalScope/fetch#Parameters).
220
233
221
234
When sending credentials (authorization cookies/headers) on CORS requests, the `Authorization` header must be allowed by the CORS policy.
@@ -239,6 +252,8 @@ For more information, see <xref:security/cors> and the sample app's HTTP Request
Copy file name to clipboardExpand all lines: aspnetcore/blazor/handle-errors.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Discover how ASP.NET Core Blazor how Blazor manages unhandled excep
5
5
monikerRange: '>= aspnetcore-3.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 03/29/2020
8
+
ms.date: 04/23/2020
9
9
no-loc: [Blazor, SignalR]
10
10
uid: blazor/handle-errors
11
11
---
@@ -106,6 +106,8 @@ During development, Blazor usually sends the full details of exceptions to the b
106
106
107
107
You must decide which incidents to log and the level of severity of logged incidents. Hostile users might be able to trigger errors deliberately. For example, don't log an incident from an error where an unknown `ProductId` is supplied in the URL of a component that displays product details. Not all errors should be treated as high-severity incidents for logging.
108
108
109
+
For more information, see <xref:fundamentals/logging/index#create-logs-in-blazor>.
110
+
109
111
## Places where errors may occur
110
112
111
113
Framework and app code may trigger unhandled exceptions in any of the following locations:
@@ -92,12 +92,21 @@ The `IWebAssemblyHostEnvironment.BaseAddress` property can be used during startu
92
92
93
93
### Configuration
94
94
95
-
As of the ASP.NET Core 3.2 Preview 3 release ([current release is 3.2 Preview 4](xref:blazor/get-started)), Blazor WebAssembly supports configuration from:
95
+
Blazor WebAssembly supports configuration from:
96
96
97
-
**wwwroot/appsettings.json*
98
-
**wwwroot/appsettings.{ENVIRONMENT}.json*
97
+
* The [File Configuration Provider](xref:fundamentals/configuration/index#file-configuration-provider) for app settings files by default:
98
+
**wwwroot/appsettings.json*
99
+
**wwwroot/appsettings.{ENVIRONMENT}.json*
100
+
* Other [configuration providers](xref:fundamentals/configuration/index) registered by the app.
99
101
100
-
Add an *appsettings.json* file in the *wwwroot* folder:
102
+
> [!WARNING]
103
+
> Configuration in a Blazor WebAssembly app is visible to users. **Don't store app secrets or credentials in configuration.**
104
+
105
+
For more information on configuration providers, see <xref:fundamentals/configuration/index>.
106
+
107
+
#### App settings configuration
108
+
109
+
*wwwroot/appsettings.json*:
101
110
102
111
```json
103
112
{
@@ -117,8 +126,113 @@ Inject an <xref:Microsoft.Extensions.Configuration.IConfiguration> instance into
117
126
<p>Message: @Configuration["message"]</p>
118
127
```
119
128
120
-
> [!WARNING]
121
-
> Configuration in a Blazor WebAssembly app is visible to users. **Don't store app secrets or credentials in configuration.**
129
+
#### Provider configuration
130
+
131
+
The following example uses a <xref:Microsoft.Extensions.Configuration.Memory.MemoryConfigurationSource> and the [File Configuration Provider](xref:fundamentals/configuration/index#file-configuration-provider) to supply additional configuration:
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/logging/index.md
+61-2Lines changed: 61 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ description: Learn how to use the logging framework provided by the Microsoft.Ex
5
5
monikerRange: '>= aspnetcore-2.1'
6
6
ms.author: riande
7
7
ms.custom: mvc
8
-
ms.date: 4/17/2020
8
+
ms.date: 4/23/2020
9
9
uid: fundamentals/logging/index
10
10
---
11
11
# Logging in .NET Core and ASP.NET Core
@@ -159,7 +159,9 @@ If you need to configure a service that depends on `ILogger<T>`, you can still d
159
159
160
160
The preceding highlighted code is a `Func` that runs the first time the DI container needs to construct an instance of `MyService`. You can access any of the registered services in this way.
161
161
162
-
### Create logs in Blazor WebAssembly
162
+
### Create logs in Blazor
163
+
164
+
#### Blazor WebAssembly
163
165
164
166
Configure logging in Blazor WebAssembly apps with the `WebAssemblyHostBuilder.Logging` property in `Program.Main`:
The `Logging` property is of type <xref:Microsoft.Extensions.Logging.ILoggingBuilder>, so all of the extension methods available on <xref:Microsoft.Extensions.Logging.ILoggingBuilder> are also available on `Logging`.
178
180
181
+
#### Log in Razor components
182
+
183
+
Loggers respect app startup configuration.
184
+
185
+
The `using` directive for <xref:Microsoft.Extensions.Logging> is required to support Intellisense completions for APIs, such as <xref:Microsoft.Extensions.Logging.LoggerExtensions.LogWarning%2A> and <xref:Microsoft.Extensions.Logging.LoggerExtensions.LogError%2A>.
186
+
187
+
The following example demonstrates logging with an <xref:Microsoft.Extensions.Logging.ILogger> in Razor components:
var logger = LoggerFactory.CreateLogger<Counter>();
231
+
logger.LogWarning("Someone has clicked me!");
232
+
233
+
currentCount++;
234
+
}
235
+
}
236
+
```
237
+
179
238
### No asynchronous logger methods
180
239
181
240
Logging should be so fast that it isn't worth the performance cost of asynchronous code. If your logging data store is slow, don't write to it directly. Consider writing the log messages to a fast store initially, then move them to the slow store later. For example, if you're logging to SQL Server, you don't want to do that directly in a `Log` method, since the `Log` methods are synchronous. Instead, synchronously add log messages to an in-memory queue and have a background worker pull the messages out of the queue to do the asynchronous work of pushing data to SQL Server. For more information, see [this](https://github.com/dotnet/AspNetCore.Docs/issues/11801) GitHub issue.
0 commit comments