Vulnerability in EPiServer.Forms
Best is to pass it or the properties you need from your controller to the view.
public ActionResult Index(PageData currentPage)
// code here
You can also access it directly (bad pattern):
var contentRouteHelper = ServiceLocator.Current.GetInstance<IContentRouteHelper>();
contentRouteHelper.Content as PageData
Hope this helps.
Thank you - although i am trying to get this in a view without a controller. Why is your second solution a bad pattern?
More logic in view. Logic should be contained in controller or even better in the service layer below controller. More logic in view => harder to read presentation and more difficult to maintain solution if logic is scattered around solution. Single responsibility principle, MVC pattern etc...
Use a LayoutModel like in Alloy sample site, or an action method with the ChildActionAttribute.