@@ -83,9 +83,6 @@ dotnet new webapp --output TestAppConfig --framework netcoreapp3.1
83
83
#### [.NET 6.x](#tab/core6x)
84
84
85
85
```csharp
86
- // Existing code in Program.cs
87
- // ... ...
88
-
89
86
var builder = WebApplication.CreateBuilder(args);
90
87
91
88
// Retrieve the connection string
@@ -183,26 +180,25 @@ In this example, you'll update a web page to display its content using the setti
183
180
184
181
---
185
182
186
- 1. Open *Index.cshtml.cs* in the *Pages* directory and update it with the following code.
183
+ 1. Open *Index.cshtml.cs* in the *Pages* directory and update it with the following code. Add the `using Microsoft.Extensions.Options` namespace.
187
184
188
185
```csharp
189
186
using Microsoft.AspNetCore.Mvc.RazorPages;
190
187
using Microsoft.Extensions.Options;
191
188
192
- namespace TestAppConfig.Pages
189
+ namespace TestAppConfig.Pages;
190
+
191
+ public class IndexModel : PageModel
193
192
{
194
- public class IndexModel : PageModel
195
- {
196
- private readonly ILogger<IndexModel> _logger;
197
-
198
- public Settings Settings { get; }
199
-
200
- public IndexModel(IOptionsSnapshot<Settings> options, ILogger<IndexModel> logger)
201
- {
202
- Settings = options. Value;
203
- _logger = logger;
204
- }
205
- }
193
+ private readonly ILogger<IndexModel> _logger;
194
+
195
+ public Settings Settings { get; }
196
+
197
+ public IndexModel(IOptionsSnapshot<Settings> options, ILogger<IndexModel> logger)
198
+ {
199
+ Settings = options.Value;
200
+ _logger = logger;
201
+ }
206
202
}
207
203
```
208
204
0 commit comments