Editable Page Builder not working in Kentico 12 MVC

jeff McDaniel asked on January 25, 2019 00:35

Hey everyone,

I'm working on setting up the page builder in the admin interface of Kentico 12 MVC. I have been following the tutorial and have been getting stuck when actually looking at the preview page/page builder. I'm having an issue under the Page tab. The Page tab isn't loading the "editable page" or anything at all for that.

It is showing a 404 error and saying Server Error in '/' Application.

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /cmsctx/pv/administrator/culture/en-US/wg/218d9733-0027-46b9-afaa-71204ba2b677/readonly/0/ea/1/h/25bb70bd3859dc13d1fa1405e7994a1917ac11d6be830224066a867c1c67ed7a/-/

When looking at the Event log, it shows this error

Message: This preview URL has already expired. Please contact a responsible person to provide you with a valid preview URL.

The URL Pattern I set for this page type is '/' and I've tried /Home. This is also just testing the home/root page.

I've added the page builder code in my Global.asax.cs

 // Gets the ApplicationBuilder instance
            // Allows you to enable and configure Kentico MVC features
            ApplicationBuilder builder = ApplicationBuilder.Current;

            // Enables the preview feature
            builder.UsePreview();

            // Enables the page builder feature
            builder.UsePageBuilder();

I've also added the code snippit to search for the home page in the home controller.

TreeNode page = DocumentHelper.GetDocuments()
                    .Path("/Home")
                    .OnCurrentSite()
                    .TopN(1)
                    .FirstOrDefault();

            // Returns a 404 error when the retrieving is unsuccessful
            if (page == null)
            {
                return HttpNotFound();
            }

            // Initializes the page builder with the DocumentID of the page
            HttpContext.Kentico().PageBuilder().Initialize(page.DocumentID);

            return View();

Lastly, in the view I added the PageBuilderStyles and PageBuilderScripts()

Thanks for any help!

Correct Answer

Trevor Fayas answered on January 30, 2019 07:12

Ran into the same thing, error message doesn't help. For be the macros security hash in the appsettings value was different on the Kentico admin and mvc. Check that!

5 votesVote for this answer Unmark Correct answer

Recent Answers


Zach Perry answered on January 25, 2019 16:23

I would add logging and see if this is what is getting hit:

  if (page == null)
            {
                return HttpNotFound();
            }

I used this for the URL Pattern:

{%NodeAliasPath%}

0 votesVote for this answer Mark as a Correct answer

jeff McDaniel answered on January 29, 2019 17:45

Hey Zach,

No luck on those suggestions. It appears that the controller isn't getting hit.

Does the controller get hit in preview mode? I enabled debugging and stepped through the code and it gets hit when visiting the live page, but not if I try to check through preview mode.

Do you have any other ideas I can try? Originally I just had page builder enabled but I went through and enabled preview mode as well.

0 votesVote for this answer Mark as a Correct answer

jeff McDaniel answered on January 30, 2019 18:03

Thanks Trevor! That was exactly it. That error message was not helpful whatsoever haha.

Thanks for the support!

0 votesVote for this answer Mark as a Correct answer

S T answered on December 20, 2019 14:23

Hi Jeff. I have the same problem but I cannot seem to understand what Trevor is saying? I know where the CMSHashStringSalt string is in web config, but what do you mean with "Kentico admin and mvc". To what string do I need to compare it to ?

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on December 20, 2019 14:34

Both the admin (CMS folder) and your mvc site are two different web applications and thus have their own web.configs with their own appsettings in them. The hash string salt must match on both, and then run the system - macros - resign macros just in case.

0 votesVote for this answer Mark as a Correct answer

S T answered on December 20, 2019 15:24

Hi Trevor, Thank you now I know what you meant. I looked it up and the hash salts were the same, but I've resigned them just in case but with no luck, I still can't see the editable zone.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on December 20, 2019 15:32

Shoot me an email and I'll try to find a time to screen share and help ya, http://devtrev.com/Contact

0 votesVote for this answer Mark as a Correct answer

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