Version 12 SP MVC - Page tab shows 404 error

Gregg Duncan asked on September 30, 2020 21:03

I'm following the Tutorial for creating an MVC site for Kentico version 12. I created the home page 'page type' and gave it a URL Pattern of '/Home' just as the tutorial says. I set the Presentation url to the MVC site url. But I still get a 404 error when I go to the 'Page' tab of the home page. the 404 shows the requested URL as:

Requested URL: /cmsctx/pv/r41162/culture/en-US/wg/539cb240-826b-40a7-96f8-a353d1945003/readonly/0/ea/1/h/49162d9a19b014f6d87f798c1744a4ac5975a48615b1d8be6207bf5d78697385/-/home

Note the '/readonly/0/ea/1'. If not for this section of the url it would be the same as the Preview URL from the general tab. And that URL works.

I've found several people asking the same question but I've been through all of those solutions and none of them are working for me.

Correct Answer

Gregg Duncan answered on October 2, 2020 20:45

That pointed me in the right direction. It appears the NuGet package had gotten updated to 12.0.87 but the site was still on 12.0.29. I updated the site to the 12.0.87 and it's working now.

Thanks for your help.

0 votesVote for this answer Unmark Correct answer

Recent Answers


David te Kloese answered on October 1, 2020 09:28

Can you share exactly what tutorial are you following?

If the page doesn't work in some context it might be due to you're either retrieving the wrong document by something like culture or you don't pull in the correctly version (e.g. a new page that is not published yet).

Does the sample Dancing goat site work properly for you? Anything else you can share that you've already tried?

0 votesVote for this answer Mark as a Correct answer

Gregg Duncan answered on October 1, 2020 16:32 (last edited on October 1, 2020 17:03)

The page displays fine on the MVC side it is the display in the Page tab of the admin side that doesn't work. I have only one culture en-US it is set as the default culture so I'm not pulling the wrong culture. The page tab should display whether the content it published or not. How can you add widgets to a page if you can't see the page tab.

I don't have the Dancing Goat site installed so, no it's not working.

The tutorial is here: https://docs.kentico.com/k12sptutorial/mvc-development

Is there a better tutorial somewhere because this one is not very good. There is no help trouble shooting anything they assume everything the tutorial says to do will work but it doesn't. The tutorial says to mark the 'use page tab' checkbox in the Page Type, which I did. But if you mark the 'use page tab' checkbox you get an error when you try to add a page using that page type. An error occurred while attempting to retrieve page templates. Contact your system administrator and check that the page builder feature is registered correctly in the MVC project.

But if you unmark the 'use page tab' you can add the page without it throwing this error. Then if you go back and mark the 'use page tab' the page tab shows up but the page will not display.

I believe the page builder feature is registered correctly. Here's the Global.asax:

protected void Application_Start()
    {
        // Enables and configures selected Kentico ASP.NET MVC integration features
        ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);

        //Registers routes including system routes for enabled features
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        // Registers enabled bundles
        BundleConfig.RegisterBundles(BundleTable.Bundles);
    }    

And my Application.Config is:

public static void RegisterFeatures(IApplicationBuilder builder)
{
    // Enable required Kentico features

    // Uncomment the following to use the Page builder feature
    builder.UsePreview();
    builder.UsePageBuilder();
}

I've gone back through the tutorial several times to make sure everything is set as instructed. I have the Presentation URL set properly I have '/Home' set as the URL Pattern on the Page Type. and I believe I have page builder properly registered but still the page tab still throws the 404 error.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on October 2, 2020 06:51

I just tried following the tutorial on a clean Kentico 12 instance and I do not have any issues. Please keep in mind that it could be related to environment setup and it is not possible to describe every possible configuration in the tutorial or in the documentation. There could be several reasons for this issue:
Do you have the controller code in place with appropriate model and view? At what page of the tutorial are you now? Could you please post the MVC code? Is the controller using HttpContext.Kentico().PageBuilder().Initialize(homeNode.DocumentID); ?

What authentication type is enabled on the MVC app in the IIS? Anonymous and Forms/Windows auth. should be enabled so the Kentico app can connect and request code from the MVC app.

Does it happen in Chrome only or in other browsers too? If in Chrome only, then maybe the SameSite headers can be the cause. Although. Mozilla announced this policy too in the upcoming updates.

Are there any errors in the browser console? It could tell us more what is going on and when using MVC approach, checking the browser console, failed requests and the error in the dev tools is one of the best first steps in troubleshooting.

If you applied the hotfix, were the NuGet packages in the MVC app also updated to match the hotfix? Was the project build in VS without any issues?

Are you using any request filtering in the IIS? If yes, you may need to allow unlisted verbs or explicitly allow the OPTIONS, maybe you have something like this in the MVC app web.config:
< verbs allowUnlisted="false">
< add verb="GET" allowed="true" />
< add verb="POST" allowed="true" />
< add verb="PUT" allowed="true" />
< add verb="HEAD" allowed="true" />
< /verbs>

And you need to allow this as well
< add verb="OPTIONS" allowed="true" />

0 votesVote for this answer Mark as a Correct answer

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