Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created August 25, 2022 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgolubyev/f7abe214bea5bb9abecd18c7ce6562c7 to your computer and use it in GitHub Desktop.
Save lgolubyev/f7abe214bea5bb9abecd18c7ce6562c7 to your computer and use it in GitHub Desktop.
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