/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (app != null) { app.UseStaticHttpContextAccessor(); IServiceProvider provider = app.ApplicationServices; AutoMapperService.UsePack(provider); //加载插件应用 LoadMoudleApps(env); app.UseMiniProfiler(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseSwagger(); app.UseSwaggerUI(options => { foreach (var description in apiVersionProvider.ApiVersionDescriptions) { options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json", $"{Configuration.GetSection("SwaggerDoc:Title").Value + description.GroupName.ToUpperInvariant()}"); options.RoutePrefix = string.Empty;//这里主要是不需要再输入swagger这个默认前缀 } }); app.Use((context, next) => { context.Request.EnableBuffering(); return(next()); }); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); //跨域 app.UseMiddleware <CorsMiddleware>(); app.UseCors("yuebonCors"); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("default", "api/{controller=Home}/{action=Index}/{id?}"); }); app.UseStatusCodePages(); } }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { IServiceProvider provider = app.ApplicationServices; AutoMapperService.UsePack(provider); //加载插件应用 ///LoadMoudleApps(env); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseAuthentication(); app.UseCors("cors"); app.UseStaticFiles(); app.UseStatusCodePages(); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Yuebon System API V1"); options.RoutePrefix = string.Empty;//这里主要是不需要再输入swagger这个默认前缀 }); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); endpoints.MapControllerRoute("default", "api/{controller=Home}/{action=Index}/{id?}"); //endpoints.MapAreaControllerRoute("areas", "{area:exists}", "api/{area:exists}/{controller=Home}/{action=Index}/{id?}"); }); // app.UseMiddleware(typeof(AuthorizeMiddleware)); }