I am getting null currentPage in Index action of a page. I have added EPiServer route as well. My controller is inherited from
PageController<MyPage> and index gets hit but with null currentPage.
Please follow the below article to create a new page.
Please explain full scenario that what are you doing with your page? Are you just accessing it? Or, please make sure you are not changing or altering the defult inheritance (PageData)?
Or anything else if you are doing with your page (if applicable).
I am implementing 404 page not found feature. I have configured in webconfig, created pages from CMS as well. But when controller action is called, currentPage is null.
So if you are accessing 404 page, here is configuration
<httpErrors errorMode="Custom" existingResponse="Auto">
<remove statusCode="404" />
<error statusCode="404" path="/404" responseMode="ExecuteURL" />
The "/404" is the page that should hit when you get 404 status. This is a page created with page type inherited with PageData.
Let me know if you are using same type of configuration. And, have you tried accessing it directly (http://mysite/404), without tring generating 404 status in site?
Here is the reference for more information.
If you want to implement the 404 in your project then just use the BVN.404Handler
For more info refer below article-
It kind of sounds that you're trying to call the page via its MVC route, rather than its Episerver route. Have you tried accessing the page via the View on website feature?
Andreas is right.
This typically happens when you invoke the controller at the default MVC route. E.g. /account/ when you have an AccountController, and the default MVC route is registered.
If you also have an Episerver page with the name, Account, the Episerver page and the default route can collide. A default MVC route would usually be needed only for a few specific controllers.
Try to remove the default route and add specific routes to those controllers instead.
When I click view on website, it opens as it has url with proper page name like http://localhost:55019/en/error-handler-page/. But when I enter http://localhost:55019/en/asdf with not proper url, currenPage is null.
For 404 configuration, are you using any module (like BVN.404Handler) or manual configuration? And, have you configured any partial router?
If you are using custom module then please check the configuration.
I am not using any module; only the settings in config as mentioned above. When I use url like http://localhost:55019/en/asdf how does routing directs it to my errorhandler controller? Like I mentioned above when I have proper page name, it works. But that is not what 404 page meant for.
Here is the related forum for custom 404 page setup with Episerver
Let me know if it helps.
It sounds like wrong URLs are not redirected to the actual CMS page (/en/error-handler-page/).
If you make such configurations in web.config, without any plugin, the configuration needs to point to that CMS page URL (choose a single language version).