Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.

 

Daniel Ovaska
Feb 9, 2021
  3825
(3 votes)

Episerver page gives 404

Short blog post about an issue I just encountered.

Scenario:

The site works great. After implementing some new functionality (a new page type with a header in our case), the start page just suddenly stops working and responds with 404. Episerver edit mode still works however. What just happened and how to solve it?

Solution:

  1. Turn on full logging to get information about routing and details around that.

  2. Logs gives this:
    2021-02-09 15:30:54,085 [43] DEBUG EPiServer.Web.Routing.Segments.Internal.NodeSegment: Url 'https://dev.customerweb.local/' was routed to content with id '5' and language was set to 'sv'
    2021-02-09 15:30:54,085 [43] TRACE EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Trying to Read the cacheKey = 'EP:LanguageBranch'
    2021-02-09 15:30:54,085 [43] TRACE EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Trying to Read the cacheKey = 'EP:LanguageBranch'
    2021-02-09 15:30:54,085 [43] TRACE EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Trying to Read the cacheKey = 'EPPageData:5'
    2021-02-09 15:30:54,085 [43] TRACE EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Trying to Read the cacheKey = 'EPPageData:5:sv'
    2021-02-09 15:30:54,085 [43] TRACE EPiServer.Framework.Cache.ObjectInstanceCacheExtensions: Trying to Read the cacheKey = 'EPPageData:5'
    2021-02-09 15:30:54,086 [43] DEBUG EPiServer.Web.TemplateResolver: StartPage: Selected CustomerName.Web.Features.SiteLayout.header.HeaderController. (tag='', channel='', category='MvcController')
    2021-02-09 15:30:54,063 [134] ERROR EPiServer.Global: Unhandled exception in ASP.NET
    System.Web.HttpException (0x80004005): The file '/link/43F936C99B234EA397B261C538AD07C9.aspx' does not exist.
  3. The first line in log tells you that Episerver was successful in routing to the correct content, it has id 5 and also the language 'sv'. Yey! So far so good!
  4. The debug line before the error however
    TemplateResolver: StartPage: Selected CustomerName.Web.Features.SiteLayout.header.HeaderController
    Wuuut?! It's trying to use the new HeaderController to render the page with!? Aha!
  5. The newly developed HeaderController looks like this:
    public class HeaderController : PageController<SitePageData>
    Unfortunately the controller that renders the startpage looks like this:
    public class DefaultPageController : PageController<SitePageData>
    So what happens is that Episerver gets confused what controller it should use to render the startpage. Earlier it used the DefaultsPageController and everything was fine but now with the new HeaderController, it selected that one instead. This is also visible in the logs 
    TemplateResolver: StartPage: Selected CustomerName.Web.Features.SiteLayout.header.HeaderController
  6. Solution: Make the controllers more specific to avoid letting Episervers TemplateResolver guess. The short story is to be careful when using common parent classes like SitePageData in our case. It's a bad idea to have two controllers handling that. There is a nice detailed guide here:
    https://world.episerver.com/documentation/developer-guides/CMS/rendering/selecting-templates/ 

Hope that helps someone googling 404 issues with Episerver. Check your logs and check that it's the right controller that is assigned to handle the call to your content or you can get funny issues. 

Happy coding!

Feb 09, 2021

Comments

Please login to comment.
Latest blogs
Level Up with Optimizely's Newly Relaunched Certifications!

We're thrilled to announce the relaunch of our Optimizely Certifications—designed to help partners, customers, and developers redefine what it mean...

Satata Satez | Jan 14, 2025

Introducing AI Assistance for DBLocalizationProvider

The LocalizationProvider for Optimizely has long been a powerful tool for enhancing the localization capabilities of Optimizely CMS. Designed to ma...

Luc Gosso (MVP) | Jan 14, 2025 | Syndicated blog

Order tabs with drag and drop - Blazor

I have started to play around a little with Blazor and the best way to learn is to reimplement some old stuff for CMS12. So I took a look at my old...

Per Nergård | Jan 14, 2025

Product Recommendations - Common Pitfalls

With the added freedom and flexibility that the release of the self-service widgets feature for Product Recommendations provides you as...

Dylan Walker | Jan 14, 2025

My blog is now running using Optimizely CMS!

It's official! You are currently reading this post on my shiny new Optimizely CMS website.  In the past weeks, I have been quite busy crunching eve...

David Drouin-Prince | Jan 12, 2025 | Syndicated blog

Developer meetup - Manchester, 23rd January

Yes, it's that time of year again where tradition dictates that people reflect on the year gone by and brace themselves for the year ahead, and wha...

Paul Gruffydd | Jan 9, 2025