Webiant Logo Webiant Logo
  1. No results found.

    Try your search with a different keyword or use * as a wildcard.

NopStaticFilesStartup.cs

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Nop.Core.Infrastructure;
using Nop.Web.Framework.Infrastructure.Extensions;

namespace Nop.Web.Framework.Infrastructure;

/// 
/// Represents class for the configuring routing on application startup
/// 
public partial class NopStaticFilesStartup : INopStartup
{
    /// 
    /// Add and configure any of the middleware
    /// 
    /// Collection of service descriptors
    /// Configuration of the application
    public void ConfigureServices(IServiceCollection services, IConfiguration configuration)
    {
        //compression
        services.AddResponseCompression();

        //middleware for bundling and minification of CSS and JavaScript files.
        services.AddNopWebOptimizer();
    }

    /// 
    /// Configure the using of added middleware
    /// 
    /// Builder for configuring an application's request pipeline
    public void Configure(IApplicationBuilder application)
    {
        //use response compression before UseNopStaticFiles to support compress for it
        application.UseNopResponseCompression();

        //WebOptimizer should be placed before configuring static files
        application.UseNopWebOptimizer();

        //use static files feature
        application.UseNopStaticFiles();
    }

    /// 
    /// Gets order of this startup configuration implementation
    /// 
    public int Order => 99; //Static files should be registered before routing & custom middlewares
}