Created
March 24, 2018 07:44
-
-
Save configureappio/963568bb44b917d063c2d7132c752a20 to your computer and use it in GitHub Desktop.
Example of controller taking the domain object for configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomeController : Controller | |
{ | |
private readonly MyAppSettings _settings; | |
public HomeController(MyAppSettings settings) | |
{ | |
_settings = settings ?? throw new ArgumentNullException(nameof(settings)); | |
} | |
public IActionResult Index() | |
{ | |
return View(_settings); | |
} | |
public IActionResult Error() | |
{ | |
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment