分类 默认分类 下的文章

特性:必须全局打开,谨慎使用,优先考虑 原生五种过滤器。

builder.Host.UserServiceProviderFactory(New AutofactServiceProviderFactory());

允许类中使用属性注入:
builder.registerRegisterType().AS().PropertiesAutowired();

builder.registerRegisterType().AS().SingleInstance();//设置为静态单例,也可用类似方式设置为Scoped。

https://www.cnblogs.com/Chary/p/11351457.html

通常意义上的三层架构是指:

表示层 / 表现层 / (用户)界面层(UI:User Interface layer)

业务逻辑层 / 应用程序层 / 领域层(BLL:Business Logic Layer)

数据访问层 / 数据层 / 持久层(DAL:Data access layer)

与标准默认WebApi区别:
缺少:

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();   

app.UserHttpsRedirection();
app.UseAuthorization();
app.MapControllers();


var builder = webApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/", () => "Hello world!");
var app =webApplication .Create(args);
app.MapGet("/", () => "This is a GET");
app.MapPost("/",()=> "This is a POST");
app.MapPut("/", () => "This is a PUT");
app.MapDeleteC"/", () => "This is a DELETE");
app.Run();

这里的第一个参数可以进行路由约束,如app. MapGet("/posts/ {slug:regex(^[a-z0-9_ -]+5)}",(string slug) => $"Post
{slug}");

  • 自定类型

简单或复杂数据结构;

  • IActionResult

返回指定Http状态码;

  • Ok()
  • NotFound()

-ActionResult
可同时返回状态码及对象。
返回值为ActionResult< ItemClass>