AutoFac
特性:必须全局打开,谨慎使用,优先考虑 原生五种过滤器。
builder.Host.UserServiceProviderFactory(New AutofactServiceProviderFactory());
允许类中使用属性注入:
builder.registerRegisterType
builder.registerRegisterType
特性:必须全局打开,谨慎使用,优先考虑 原生五种过滤器。
builder.Host.UserServiceProviderFactory(New AutofactServiceProviderFactory());
允许类中使用属性注入:
builder.registerRegisterType
builder.registerRegisterType
通常意义上的三层架构是指:
表示层 / 表现层 / (用户)界面层(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}");
简单或复杂数据结构;
返回指定Http状态码;
-ActionResult
可同时返回状态码及对象。
返回值为ActionResult< ItemClass>
Post传递数据:
Axios 在RequestPayload中传递Json格式;
Ajax 在QueryStringParameter(Form表单)中传递键值对;