.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     }

posted on 2019-03-13 11:42  ChenXinyuan  阅读(189)  评论(0编辑  收藏  举报

导航