3636using Microsoft . Extensions . Diagnostics . HealthChecks ;
3737using Microsoft . Extensions . FileProviders ;
3838using Microsoft . Extensions . Logging ;
39+ using Microsoft . Extensions . Options ;
3940using StackExchange . Redis ;
4041
4142namespace GeneXus . Application
@@ -206,6 +207,8 @@ public void ConfigureServices(IServiceCollection services)
206207 . AddCheck ( "liveness" , ( ) => HealthCheckResult . Healthy ( ) , tags : new [ ] { "live" } )
207208 . AddCheck ( "readiness" , ( ) => HealthCheckResult . Healthy ( ) , tags : new [ ] { "ready" } ) ;
208209
210+ services . Configure < MimeMappingsOptions > ( Config . ConfigRoot . GetSection ( "MimeMappings" ) ) ;
211+
209212 IMvcBuilder builder = services . AddMvc ( option =>
210213 {
211214 option . EnableEndpointRouting = false ;
@@ -230,7 +233,8 @@ public void ConfigureServices(IServiceCollection services)
230233 } ) ;
231234 services . AddDistributedMemoryCache ( ) ;
232235 services . AddLogging ( builder => builder . AddConsole ( ) ) ;
233- services . Configure < FormOptions > ( options =>
236+ services . Configure < FormOptions > ( Config . ConfigRoot . GetSection ( "FormOptions" ) ) ;
237+ services . PostConfigure < FormOptions > ( options =>
234238 {
235239 if ( Config . GetValueOf ( "MaxFileUploadSize" , out string MaxFileUploadSizeStr ) && long . TryParse ( MaxFileUploadSizeStr , out long MaxFileUploadSize ) )
236240 {
@@ -513,7 +517,10 @@ private void ConfigureSessionService(IServiceCollection services, ISessionServic
513517 }
514518 }
515519 }
516- public void Configure ( IApplicationBuilder app , Microsoft . AspNetCore . Hosting . IHostingEnvironment env , ILoggerFactory loggerFactory , IHttpContextAccessor contextAccessor , Microsoft . Extensions . Hosting . IHostApplicationLifetime applicationLifetime )
520+ public void Configure ( IApplicationBuilder app , Microsoft . AspNetCore . Hosting . IHostingEnvironment env , ILoggerFactory loggerFactory ,
521+ IHttpContextAccessor contextAccessor ,
522+ Microsoft . Extensions . Hosting . IHostApplicationLifetime applicationLifetime ,
523+ IOptions < MimeMappingsOptions > mimeMappingsOptions )
517524 {
518525 // Registrar para el graceful shutdown
519526 applicationLifetime . ApplicationStopping . Register ( OnShutdown ) ;
@@ -541,6 +548,14 @@ public void Configure(IApplicationBuilder app, Microsoft.AspNetCore.Hosting.IHos
541548 provider . Mappings [ ".sfb" ] = "model/sfb" ;
542549 provider . Mappings [ ".gltf" ] = "model/gltf+json" ;
543550 provider . Mappings [ ".ini" ] = "text/plain" ;
551+
552+ if ( mimeMappingsOptions ? . Value != null )
553+ {
554+ foreach ( var mapping in mimeMappingsOptions . Value )
555+ {
556+ provider . Mappings [ mapping . Key ] = mapping . Value ;
557+ }
558+ }
544559 if ( GXUtil . CompressResponse ( ) )
545560 {
546561 app . UseResponseCompression ( ) ;
@@ -959,5 +974,5 @@ public static IApplicationBuilder UseAsyncSession(this IApplicationBuilder app)
959974 return app ;
960975 }
961976 }
962-
977+ public class MimeMappingsOptions : Dictionary < string , string > { }
963978}
0 commit comments