WebOptimizer icon indicating copy to clipboard operation
WebOptimizer copied to clipboard

Not working on production environment

Open ufalak opened this issue 6 years ago • 2 comments

On a local environment works only with JS files. When deploy to the server just nothing happened. All the js and css files are normal without minification.

ufalak avatar Sep 17 '19 21:09 ufalak

I can confirm that it works on my local machine, in a docker container, and in an IIS server. What version of ASP.NET Core are you using? What version of WebOptimizer are you using? What is different in your code for the different environments?

skimedic avatar Sep 18 '19 20:09 skimedic

My ASP.NET Core version is 2.2 Web Optimizer version is 1.0.236

What is different in your code for the different environments? I think nothing.

This is my startup code:

  public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc(
                config =>
                {
                    config.Filters.Add(typeof(ExceptionHandlerAttribute));
                    
                }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
                .AddJsonOptions(options => {
                    options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                });

            /*MinutosTimeOut es seteado únicamente aqui, si cambia el valor, se debe reiniciar la aplicación*/
            services.AddSession(options => {
                options.IdleTimeout = TimeSpan.FromMinutes(AppSettingsHelper.Session.MinutosTimeOut);
                options.Cookie.Name = "st"+new Random().Next();
                options.Cookie.IsEssential=true;
            });
            services.AddWebOptimizer();
            services.AddScoped<ValidacionesDeAccesoFilterAttribute>();
            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
            services.AddHttpClient();
        }
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger, IHttpClientFactory iHttpClientFactory)
        {
            LoggingHelper.LoggerFactory = logger;
			SmartTimeRestServiceApi.CallWebService.UrlBase = AppSettingsHelper.SmartTimeApi.UrlBase;
            SmartTimeRestServiceApi.CallWebService.Subdominio= AppSettingsHelper.SmartTimeApi.Subdominio;
            SmartTimeRestServiceApi.CallWebService.Logger= logger.CreateLogger<SmartTimeRestServiceApi.CallWebService>();
            SmartTimeRestServiceApi.CallWebService.getHttpClientFabricado = GetHttpClientFabricado;
            HttpClientFactory = iHttpClientFactory;
            app.UseSession();
            Session.Configure(app.ApplicationServices.GetRequiredService<IHttpContextAccessor>());
            app.UseWebOptimizer();
            if (env.IsDevelopment())
            {
                logger.CreateLogger("Startup").LogInformation("Inicio en environment Development");
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                logger.CreateLogger("Startup").LogInformation("Inicio en environment no Development");
                app.UseExceptionHandler(Constantes.ErrorInesperado);
            }
            
            app.UseStaticFiles();
            app.UseMiddleware<RequestHandler>();
            ConfigureLocalization(app);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
                routes.MapRoute(
                    name: "login",
                    template: "{controller=Seguridad}/{action=Login}/{id?}");

            });
        }

ufalak avatar Sep 18 '19 20:09 ufalak