Try our conversational search powered by Generative AI!

CurrentPage shows StartPage when block or commece-page renders?

Vote:
 

The information i would like to get is the currentPage i am at so that i could use this information without having to forward it to my functions.

However, when i use an Block and checking its CurrentPage, it always return "StartPage".

The same thing happens when I am in the Commerce pages (Category, Product, Variant) if i want to use the following code to get the current page:

var pageRouteHelper = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance();
return pageRouteHelper.Page;

As the results differs if i am on a CMS page (works great), Commerce content page or block, is it a bug or have I missed something?

#113252
Nov 17, 2014 10:48
Vote:
 

Hi

If you use pageRouteHelper.Content, instead of pageRouteHelper.Page, do you get the correct content object or still the start page?

At least in the commerce case I would expect that the Content property would give you the current catalog item, and the Page property would give you the root page of the partial route that handles the commerce request (which is the start page in the default configuration).

Regards

Per Gunsarfs

#113256
Nov 17, 2014 11:50
Vote:
 

Thank you!

Seem to work when using "Content" always instead of "Page"! .Content gives you either the CMS page or the Content based on what you visit. Seems like Page does not work with Commerce pages and always returns StartPage.

#113261
Nov 17, 2014 12:38
Vote:
 

I'm glad it worked for you.

I think that .Page returning the start page is technically correct in the Commerce, although if that is not what would be expected we should consider improving it. But as long as your problem is solved I'm happy.

#113263
Nov 17, 2014 13:05
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.