.net core web

 

创建一个空web应用

dotnet new web -n myweb

 

1.appsettings.json : 配置文件

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },
  "AllowedHosts": "*"
}

 

2.Program :main函数的所在地

        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
          return  WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
        }

 

3.Startup:

    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
        }
    }

 

ConfigureServices方法用来用来添加服务的集合

 

Configure 中间件组件组成的请求处理管道

 

posted @ 2018-08-17 14:14  富坚老贼  阅读(309)  评论(0编辑  收藏  举报