Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

CMS 12 upgrade only shows 404 for any path



We are in the process of upgrading from CMS 11 to CMS 12. Errors are fixed and we can compile and run. Program.cs and Startup.cs was largely taken from the Alloy template to have something to start with. Database filled with a lot of pages from CMS 11.

When starting the application locally (and testing against local IIS) I get a 404 Not found when trying paths with known pages. Some things I have tested:

- I know that the page exists in the database, and has controller, view etc.
- Browsing to https://localhost:54806 hits StartPage (as in the routing directive), with currentPage is null. I tried getting a page by pageId of a known existing page in the StartPage controller to try to see if the database connection was OK and it returned the requested page, so database connection works.
- http://cms12.local/EPiServer redirects to http://cms12.local/EPiServer/Shell/Readonly

Log shows:

info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
      Request starting HTTP/2 GET https://localhost:54806/path/to/page - - -
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
      Request finished HTTP/2 GET https://localhost:54806/path/to/page - 404 0 - 3.4802ms
info: Microsoft.AspNetCore.Hosting.Diagnostics[16]
      Request reached the end of the middleware pipeline without being handled by application code. Request path: GET https://localhost:54806/path/to/page, Response status code: 404

Startup class:

public class Startup
    private readonly IWebHostEnvironment _webHostingEnvironment;

    public Startup(IWebHostEnvironment webHostingEnvironment)
        _webHostingEnvironment = webHostingEnvironment;

    public void ConfigureServices(IServiceCollection services)
            .AddSingleton<MatcherPolicy, CustomMatcherPolicy>()

        services.AddSession(options =>
            options.IdleTimeout = TimeSpan.FromSeconds(10);
            options.Cookie.HttpOnly = true;
            options.Cookie.IsEssential = true;

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        if (env.IsDevelopment())


        app.UseEndpoints(endpoints =>
            endpoints.MapControllerRoute(name: "default", pattern: "{controller=StartPage}/{action=Index}/{id?}");

Program class:

public class Program
    private static IHost _host;
    public static IHost host
    { get { return _host; } }
    public static void Main(string[] args) => CreateHostBuilder(args).Build().Run();

    public static IHostBuilder CreateHostBuilder(string[] args) =>
            .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
Jan 22, 2024 16:20

Hi Tony

I don't see MapContent() in your endpoint configuration. Add endpoints.MapContent(); before MapControllerRoute
Jan 22, 2024 23:33

Hi Vincent, thanks for replying. I had MapContent when testing around and it didn't work. But the order was important - it had to be before MapControllerRoute. It solved the problem. Many thanks :)

Jan 23, 2024 10:17
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.