vs webapi 取消controller
1、添加引用
using Panda.DynamicWebApi;
2、starup.cs
public void ConfigureServices(IServiceCollection services) { //注入HttpContextAccessor services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); //启动缓存 services.AddMemoryCache(); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddMvc(options => { options.Filters.Add<HttpGlobalExceptionFilter>(); }); //自动生成Api文档 services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { Version = "v1", Title = "API", Description = "OpenApi文档" }); options.DocInclusionPredicate((docName, description) => true); //true表示生成控制器描述,包含true的IncludeXmlComments重载应放在最后,或者两句都使用true options.IncludeXmlComments(@"bin\Debug\netcoreapp2.2\OneCode.HongYan.OpenApi.xml"); options.IncludeXmlComments(@"bin\Debug\netcoreapp2.2\OneCode.HongYan.Application.xml"); }); // 添加动态WebApi 需放在 AddMvc 之后 services.AddDynamicWebApi(); }