Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Dec 15, 2022 @ 06:19
    Mario Lopez
    0

    Exception Handler not hit when Runtime is 'Production'

    When I set up the Umbraco runtime to 'production', the custom Error controller I have in place to display the 500 errors is not hit.

    The controller is just this.

    [Route("Error")]
    public class ErrorController : Controller
    {
        public IActionResult Index()
        {            
            return View("Index");
    
        }
    }
    

    This is my Startup.cs

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment() || env.EnvironmentName == "Int")
            {            
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }
    
            app.UseHttpsRedirection();
            app.Use(async (context, next) =>
            {
                context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
                context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
                context.Response.Headers.Add("X-XSS-Protection", "1; mode=block");
                await next();
            });
    
            app.UseMvc(routeBuilder =>
            {
                routeBuilder.Expand().Select().Filter().OrderBy().MaxTop(100).Count().SetTimeZoneInfo(TimeZoneInfo.Utc);
                routeBuilder.MapRestier(u =>
                {
                    u.MapApiRoute<AcpccApi>("ApiV1", "dataApi", true);
                });
                routeBuilder.EnableDependencyInjection();
    
            });
            app.UseRouting();
            app.UseUmbraco()
                .WithMiddleware(u =>
                {
                    u.UseBackOffice();
                    u.UseWebsite();
                })
                .WithEndpoints(u =>
                {
                    u.UseInstallerEndpoints();
                    u.UseBackOfficeEndpoints();
                    u.UseWebsiteEndpoints();
                });
        }
    

    If I remove the runtime setting from appsettings.json, the custom error is displayed.

  • Mario Lopez 168 posts 958 karma points MVP 4x c-trib
    Dec 16, 2022 @ 00:43
    Mario Lopez
    0

    I found this opened ticket. It seems related to this. https://github.com/umbraco/Umbraco-CMS/issues/13052

Please Sign in or register to post replies

Write your reply to:

Draft