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?
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).
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.
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.