Skip to content

Instantly share code, notes, and snippets.

@manoj-choudhari-git
Created April 18, 2021 13:49
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 manoj-choudhari-git/01f71f7e5f40311200bf011e277c7489 to your computer and use it in GitHub Desktop.
Save manoj-choudhari-git/01f71f7e5f40311200bf011e277c7489 to your computer and use it in GitHub Desktop.
IConfiguration injected in the HomeController
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IConfiguration configuration;
public HomeController(ILogger<HomeController> logger, IConfiguration configuration)
{
_logger = logger;
this.configuration = configuration;
}
public IActionResult Index()
{
// Mode is the value from in-memory database,
// populated using custom configuration provider
ViewData["Mode"] = configuration["Mode"];
return View();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment