.net core - 配置管理 - json文件配置
Posted chenxinyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了.net core - 配置管理 - json文件配置相关的知识,希望对你有一定的参考价值。
Json 文件配置
1 public class Startup 2 { 3 public Startup(IHostingEnvironment env) 4 { 5 var builder = new ConfigurationBuilder() 6 .AddJsonFile("Class.json"); 7 8 Configuration = builder.Build(); 9 } 10 11 public IConfigurationRoot Configuration { get; } 12 13 // This method gets called by the runtime. Use this method to add services to the container. 14 // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 15 public void ConfigureServices(IServiceCollection services) 16 { 17 services.AddMvc(); 18 } 19 20 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 21 public void Configure(IApplicationBuilder app, IHostingEnvironment env) 22 { 23 if (env.IsDevelopment()) 24 { 25 app.UseDeveloperExceptionPage(); 26 } 27 28 app.Run(async (context) => 29 { 30 await context.Response.WriteAsync("Hello World!"); 31 }); 32 } 33 }
以上是关于.net core - 配置管理 - json文件配置的主要内容,如果未能解决你的问题,请参考以下文章