Page template not found for unpublished pages - 12SP

Mike McDermot asked on December 29, 2020 19:15

Running Kentico 12SP

When we unpublish pages we get a "Page template not found for selected page" error. We are not using workflow. To unpublish a page we set the "Publish to:" value on the Content tab to a date in the past.

I have attached a debugger to both the custom web app and the Kentico 12SP CMS web app (content editor site) and I'm unable to break into the debugger at any point to see what might be going on.

Server Error in '/' Application.
Page template not found for selected page.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Page template not found for selected page.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidOperationException: Page template not found for selected page.]
   Kentico.PageBuilder.Web.Mvc.PageTemplates.TemplateResult.ExecuteResultInternal(IActionInvoker invoker, ControllerContext context, PageTemplateConfiguration configuration) +299
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +91
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +795
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +32
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +39
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +46
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +73
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +651
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4250.0

Recent Answers


Juraj Ondrus answered on December 29, 2020 21:08

What is the hotfix applied to your instance? Does the hotfix applied to the admin app matches the version of the Kentico NuGet packages in your MVC app? What is your MVC code for the page templates? I tried the same using the latest hotfix on the sample Dancing Goat MVC project and it is working fine. What is the URL pattern set and what is the routing like? Maybe it falls to the 404 route for some reason. Are you able to reproduce the issue using the DG MVC project too? If yes, please describe all the steps in more details and/or share the MVC code samples to use in the DG MVC project in order to reproduce the issue.

0 votesVote for this answer Mark as a Correct answer

Mike McDermot answered on December 29, 2020 22:01

Some additional background - we actually want unpublished pages to fall back to a 404, but because of the template error the server throws a 500 and the user gets our friendly error message page instead of our friendly 404 page. Is falling back to a 404 even possible? I couldn't find anything specific in the documentation....

I'll check the hotfix and nuget package versions, as well as try to reproduce using the DG reference MVC app and will follow up on this thread with updates.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.