Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created August 25, 2022 15:50
Embed
What would you like to do?
Services.AddScoped<SomeCustomType>();
[Route("[controller]")]
[ApiController]
public class MyController : ControllerBase
{
// Both actions will bound the SomeCustomType from the DI container
public ActionResult GetWithAttribute([FromServices]SomeCustomType service) => Ok();
public ActionResult Get(SomeCustomType service) => Ok();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment