0
点赞
收藏
分享

微信扫一扫

.net core web

 

创建一个空web应用

dotnet new web -n myweb

 

.net core web_Startup

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 中间件组件组成的请求处理管道

 



举报

相关推荐

0 条评论