1.新建一个Mvc Core项目
注:刚开始依赖项是有黄色三角形,等待安装
2.打开Startup.cs,修改Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env,ILogger<Startup> logger) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); app.Use(async (context, next) => { logger.LogInformation("M1 Start"); await context.Response.WriteAsync("Hello World!"); await next(); logger.LogInformation("M1 End"); }); app.Run(async (context) => { logger.LogInformation("M2 Start"); await context.Response.WriteAsync("Another World!"); logger.LogInformation("M2 End"); }); }
3.选择启动方式 FirstCore
出现:
原理:
参阅:https://v.qq.com/x/page/r0744ix6a9s.html
谢谢Dave
原文地址:https://www.cnblogs.com/dzw159/p/10549852.html
时间: 2024-11-12 02:42:59