From f72421dbf66b0097d44d26a7596b7238fa32ddbe Mon Sep 17 00:00:00 2001 From: cdk <2441919651@qq.com> Date: 星期六, 24 五月 2025 16:30:21 +0800 Subject: [PATCH] 代码调整,删除生成的包 --- MESApplication/Startup.cs | 30 +++++++++++++++++++----------- 1 files changed, 19 insertions(+), 11 deletions(-) diff --git a/MESApplication/Startup.cs b/MESApplication/Startup.cs index b764775..b6ebcfe 100644 --- a/MESApplication/Startup.cs +++ b/MESApplication/Startup.cs @@ -92,27 +92,35 @@ if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/error"); + } + app.UseSwagger(); app.UseSwaggerUI(c => { - c.InjectJavascript(""); c.SwaggerEndpoint("/swagger/v1/swagger.json", "API"); - c.DocExpansion(DocExpansion - .None); + c.DocExpansion(DocExpansion.None); c.DefaultModelsExpandDepth(-1); }); - } - app.UseCors(MyAllowSpecificOrigins); //娣诲姞杩欎釜 + // 娣诲姞鏍硅矾寰勯噸瀹氬悜涓棿浠� + app.Use(async (context, next) => + { + if (context.Request.Path == "/") + { + context.Response.Redirect("/swagger"); + return; + } + await next(); + }); + + app.UseCors(MyAllowSpecificOrigins); app.UseRouting(); - app.UseAuthorization(); - app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); - - ////////////////////////// - - /////////////////////////// } } \ No newline at end of file -- Gitblit v1.9.3