展杰
2024-08-16 3dfa3d93337cca6363b0e138c74f80af96431b83
MESApplication/Startup.cs
@@ -4,6 +4,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Swashbuckle.AspNetCore.SwaggerUI;
using System.Reflection;
namespace MESApplication;
@@ -35,6 +36,9 @@
            c.SwaggerDoc("v1",
                new OpenApiInfo
                    { Title = "MESApplication.Api", Version = "v1" });
            var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
            var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
            c.IncludeXmlComments(xmlPath, true);
        });
        //配置JSON.NET
@@ -66,6 +70,14 @@
                        "OPTIONS")
            );
        });
        #region 接口行动过滤器
        services.AddControllers(options => {
            options.Filters.Add(new ActionFilter());
        });
        var serviceProvider = services.BuildServiceProvider();
        ActionFilter.LoggerError = serviceProvider.GetRequiredService<ILogger<ActionFilter>>();
        #endregion
    }
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -92,5 +104,10 @@
        app.UseAuthorization();
        app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
        //////////////////////////
        ///////////////////////////
    }
}