Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get injected IOptions<AppSettings>

Tags:

asp.net-core

I'm trying to build my first ASP.NET vNext web application and the problem I've faced is that I can't get IOptions<AppSettings> injected to my Startup.Configure() method. The odd thing is that MVC sample site which was generated by VS2015 does the same steps but the same injecting works! Both projects are run on Desktop CLR and use 1.0.0-beta4 binaries. I have created gist with my project's files. I will appreciate any advise or help with this.

like image 702
Alexey Andrushkevich Avatar asked Aug 31 '26 17:08

Alexey Andrushkevich


1 Answers

In your ConfigureServices method, try adding the following:

services.AddOptions()

This registers OptionsManager<> which is used to resolve the services of type IOptions<>.

like image 143
Kiran Avatar answered Sep 04 '26 14:09

Kiran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!