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/fundamentals/dependency-injection.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,11 +21,11 @@ For Blazor DI guidance, which adds to or supersedes the guidance in this article
21
21
22
22
For information specific to dependency injection within MVC controllers, see <xref:mvc/controllers/dependency-injection>.
23
23
24
-
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
24
+
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
25
25
26
26
For information on dependency injection of options, see <xref:fundamentals/configuration/options>.
27
27
28
-
This article provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
28
+
This article provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
29
29
30
30
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/fundamentals/dependency-injection/samples) ([how to download](xref:fundamentals/index#how-to-download-a-sample))
31
31
@@ -109,7 +109,7 @@ The following code is generated by the Razor Pages template using individual acc
109
109
110
110
## Service lifetimes
111
111
112
-
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
112
+
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
113
113
114
114
To use scoped services in middleware, use one of the following approaches:
115
115
@@ -120,9 +120,9 @@ For more information, see <xref:fundamentals/middleware/write#per-request-middle
120
120
121
121
## Service registration methods
122
122
123
-
See [Service registration](/dotnet/core/extensions/dependency-injection/service-registration) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
123
+
See [Service registration](/dotnet/core/extensions/dependency-injection/service-registration) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
124
124
125
-
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
125
+
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
126
126
127
127
Registering a service with only an implementation type is equivalent to registering that service with the same implementation and service type. This is why multiple implementations of a service can't be registered using the methods that don't take an explicit service type. These methods can register multiple *instances* of a service, but they all have the same *implementation* type.
128
128
@@ -162,7 +162,7 @@ For more information on creating middleware, see <xref:fundamentals/middleware/w
162
162
163
163
## Constructor injection behavior
164
164
165
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
165
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
166
166
167
167
## Entity Framework contexts
168
168
@@ -212,7 +212,7 @@ The following code shows how to resolve a scoped service for a limited duration
212
212
213
213
## Scope validation
214
214
215
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
215
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
216
216
217
217
For more information, see [Scope validation](xref:fundamentals/host/web-host#scope-validation).
218
218
@@ -270,15 +270,15 @@ In the preceding code:
270
270
271
271
### IDisposable guidance for Transient and shared instances
272
272
273
-
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
273
+
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
274
274
275
275
## Default service container replacement
276
276
277
-
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
277
+
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
278
278
279
279
## Recommendations
280
280
281
-
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
281
+
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
282
282
283
283
* Avoid using the *service locator pattern*. For example, don't invoke <xref:System.IServiceProvider.GetService%2A> to obtain a service instance when you can use DI instead:
284
284
@@ -352,8 +352,8 @@ The following table lists a small sample of these framework-registered services:
352
352
*[Understand dependency injection basics in .NET](/dotnet/core/extensions/dependency-injection/basics)
*[ASP.NET Core Dependecy Injection: What is the IServiceCollection?](https://www.stevejgordon.co.uk/aspnet-core-dependency-injection-what-is-the-iservicecollection)
*[ASP.NET Core Dependency Injection: What is the IServiceCollection?](https://www.stevejgordon.co.uk/aspnet-core-dependency-injection-what-is-the-iservicecollection)
357
357
*[Four ways to dispose IDisposables in ASP.NET Core](https://andrewlock.net/four-ways-to-dispose-idisposables-in-asp-net-core/)
358
358
*[Writing Clean Code in ASP.NET Core with Dependency Injection (MSDN)](/archive/msdn-magazine/2016/may/asp-net-writing-clean-code-in-asp-net-core-with-dependency-injection)
Copy file name to clipboardExpand all lines: aspnetcore/fundamentals/dependency-injection/includes/dependency-injection-5-7.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,11 +11,11 @@ ASP.NET Core supports the dependency injection (DI) software design pattern, whi
11
11
12
12
For more information specific to dependency injection within MVC controllers, see <xref:mvc/controllers/dependency-injection>.
13
13
14
-
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
14
+
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
15
15
16
16
For more information on dependency injection of options, see <xref:fundamentals/configuration/options>.
17
17
18
-
This topic provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
18
+
This topic provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
19
19
20
20
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/fundamentals/dependency-injection/samples) ([how to download](xref:fundamentals/index#how-to-download-a-sample))
21
21
@@ -99,7 +99,7 @@ The following code is generated by the Razor Pages template using individual use
99
99
100
100
## Service lifetimes
101
101
102
-
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
102
+
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
103
103
104
104
To use scoped services in middleware, use one of the following approaches:
105
105
@@ -110,9 +110,9 @@ For more information, see <xref:fundamentals/middleware/write#per-request-middle
110
110
111
111
## Service registration methods
112
112
113
-
See [Service registration methods](/dotnet/core/extensions/dependency-injection#service-registration-methods) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
113
+
See [Service registration methods](/dotnet/core/extensions/dependency-injection/service-registration#registration-methods) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
114
114
115
-
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
115
+
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
116
116
117
117
Registering a service with only an implementation type is equivalent to registering that service with the same implementation and service type. This is why multiple implementations of a service cannot be registered using the methods that don't take an explicit service type. These methods can register multiple *instances* of a service, but they will all have the same *implementation* type.
118
118
@@ -138,7 +138,7 @@ public class MyService
138
138
139
139
## Constructor injection behavior
140
140
141
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
141
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
142
142
143
143
## Entity Framework contexts
144
144
@@ -188,7 +188,7 @@ The following code shows how to resolve a scoped service for a limited duration
188
188
189
189
## Scope validation
190
190
191
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
191
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
192
192
193
193
For more information, see [Scope validation](xref:fundamentals/host/web-host#scope-validation).
194
194
@@ -246,15 +246,15 @@ In the preceding code:
246
246
247
247
### IDisposable guidance for Transient and shared instances
248
248
249
-
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
249
+
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
250
250
251
251
## Default service container replacement
252
252
253
-
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
253
+
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
254
254
255
255
## Recommendations
256
256
257
-
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
257
+
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
258
258
259
259
* Avoid using the *service locator pattern*. For example, don't invoke <xref:System.IServiceProvider.GetService%2A> to obtain a service instance when you can use DI instead:
260
260
@@ -362,11 +362,11 @@ ASP.NET Core supports the dependency injection (DI) software design pattern, whi
362
362
363
363
For more information specific to dependency injection within MVC controllers, see <xref:mvc/controllers/dependency-injection>.
364
364
365
-
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
365
+
For information on using dependency injection in applications other than web apps, see [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
366
366
367
367
For more information on dependency injection of options, see <xref:fundamentals/configuration/options>.
368
368
369
-
This topic provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection).
369
+
This topic provides information on dependency injection in ASP.NET Core. The primary documentation on using dependency injection is contained in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
370
370
371
371
[View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/fundamentals/dependency-injection/samples) ([how to download](xref:fundamentals/index#how-to-download-a-sample))
372
372
@@ -489,7 +489,7 @@ The following code is generated by the Razor Pages template using individual use
489
489
490
490
## Service lifetimes
491
491
492
-
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
492
+
See [Service lifetimes](/dotnet/core/extensions/dependency-injection/service-lifetimes) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
493
493
494
494
To use scoped services in middleware, use one of the following approaches:
495
495
@@ -500,9 +500,9 @@ For more information, see <xref:fundamentals/middleware/write#per-request-middle
500
500
501
501
## Service registration methods
502
502
503
-
See [Service registration methods](/dotnet/core/extensions/dependency-injection#service-registration-methods) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
503
+
See [Service registration methods](/dotnet/core/extensions/dependency-injection/service-registration#registration-methods) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
504
504
505
-
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
505
+
It's common to use multiple implementations when [mocking types for testing](xref:test/integration-tests#inject-mock-services).
506
506
507
507
Registering a service with only an implementation type is equivalent to registering that service with the same implementation and service type. This is why multiple implementations of a service cannot be registered using the methods that don't take an explicit service type. These methods can register multiple *instances* of a service, but they will all have the same *implementation* type.
508
508
@@ -528,7 +528,7 @@ public class MyService
528
528
529
529
## Constructor injection behavior
530
530
531
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
531
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
532
532
533
533
## Entity Framework contexts
534
534
@@ -582,7 +582,7 @@ The following example shows how to access the scoped `IMyDependency` service and
582
582
583
583
## Scope validation
584
584
585
-
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
585
+
See [Constructor injection behavior](/dotnet/core/extensions/dependency-injection/overview#constructor-injection-behavior) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
586
586
587
587
For more information, see [Scope validation](xref:fundamentals/host/web-host#scope-validation).
588
588
@@ -640,15 +640,15 @@ In the preceding code:
640
640
641
641
### IDisposable guidance for Transient and shared instances
642
642
643
-
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
643
+
See [IDisposable guidance for Transient and shared instance](/dotnet/core/extensions/dependency-injection/guidelines#idisposable-guidance-for-transient-and-shared-instances) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
644
644
645
645
## Default service container replacement
646
646
647
-
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
647
+
See [Default service container replacement](/dotnet/core/extensions/dependency-injection/guidelines#default-service-container-replacement) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
648
648
649
649
## Recommendations
650
650
651
-
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection)
651
+
See [Recommendations](/dotnet/core/extensions/dependency-injection/guidelines#recommendations) in [Dependency injection in .NET](/dotnet/core/extensions/dependency-injection/overview).
652
652
653
653
* Avoid using the *service locator pattern*. For example, don't invoke <xref:System.IServiceProvider.GetService%2A> to obtain a service instance when you can use DI instead:
0 commit comments