ASP.Net 5 MVCで再生する。この質問は、完全な答えではなく飛び回っています。私がしたいことは、AppSettingsにアクセスできるヘルパークラスを持つことです。私はコントローラとビューでアクセスできますが、自分のカスタムクラスでアクセスする方法を理解していません。そうしたスタートアップを設定してください。カスタムクラスのアプリケーション設定ASP.Net 5 MVC 6
public Startup(IHostingEnvironment env)
{
// Set up configuration sources.
var builder = new ConfigurationBuilder()
.AddJsonFile("config.json")
.AddJsonFile($"config.{env.EnvironmentName}.json", optional: true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
}
public IConfigurationRoot Configuration { get; set; }
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddOptions();
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
}
.................
.................