net-core理解
环境:net core 7.0
第一行代码:
var builder = WebApplication.CreateBuilder(args); // 1 忘记了Application,创建ApplicationBuilder Microsoft.AspNetCore.Builder
第二行代码:
builder.Services.AddControllers();
private static IMvcCoreBuilder AddControllersCore(IServiceCollection services)
{
// This method excludes all of the view-related services by default.
var builder = services
.AddMvcCore()
.AddApiExplorer()
.AddAuthorization()
.AddCors()
.AddDataAnnotations()
.AddFormatterMappings();
if (MetadataUpdater.IsSupported)
{
services.TryAddEnumerable(
ServiceDescriptor.Singleton<IActionDescriptorChangeProvider, HotReloadService>());
}
return builder;
}