Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

MvcCoreServiceCollectionExtensions retrieves first registered service instead of last #5554

@Eilon

Description

@Eilon

This line:

https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/MvcCoreServiceCollectionExtensions.cs#L90

Per @danroth27 :

When you request a service from the built service provider it will give you the last service added, not the first one. This method should mimic the DI behavior.

This issue doesn't generally affect user scenarios today, because this method is used to extract the hosting environment service and there is typically only one of those. I hit this issue as part of my module prototyping when I added a new hosting environment for each module. The added hosting environment should override the existing one, but currently it doesn't because this method picks the first instead of the last. I'm working around this right now by simply removing the app hosting environment for each module and then replacing it with a new one.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions