src/Dangl.Data.Shared.AspNetCore/SpaUtilities/LocalizedSpaStaticFileExtensions.cs
/// <summary>
/// This configures the localized SPA serving in the app pipeline. It should be called as
/// last step in the config, since it will serve the SPA index file for all requests.
/// </summary>
/// <param name="applicationBuilder"></param>
/// <param name="defaultFile"></param>
This configures the localized SPA serving in the app pipeline. It should be called as
last step in the config, since it will serve the SPA index file for all requests.
This configures the localized SPA serving in the app pipeline . It should be called as last step in the config since it will serve the SPA index file for all requests .
public static void UseLocalizedSpaStaticFiles(this IApplicationBuilder applicationBuilder, string defaultFile)
        {
            applicationBuilder.Use((context, next) =>
            {
                var spaFilePathProvider = context.RequestServices.GetRequiredService<LocalizedSpaStaticFilePathProvider>();
                context.Request.Path = spaFilePathProvider.GetRequestPath("/" + defaultFile.TrimStart('/'));
                return next();
            });
            applicationBuilder.UseStaticFiles();
        }
public static void UseLocalizedSpaStaticFiles ( this IApplicationBuilder applicationBuilder , string defaultFile ) { applicationBuilder . Use ( ( context , next ) => { var spaFilePathProvider = context . RequestServices . GetRequiredService < LocalizedSpaStaticFilePathProvider > ( ) ; context . Request . Path = spaFilePathProvider . GetRequestPath ( " " + defaultFile . TrimStart ( ' ' ) ) ; return next ( ) ; } ) ; applicationBuilder . UseStaticFiles ( ) ; }
This configures the localized SPA serving in the app pipeline.
This configures the localized SPA serving in the app pipeline .
// In this part of the pipeline, the request path is altered to point to a localized SPA asset
IApplicationBuilder
this
defaultFile
string
None
applicationBuilder
None