You are trying 3 different ways to pass the data from the controller to the view. Why use viewbag and tempdata?
Maybe try something like this?
MultiDocumentQuery pg = DocumentHelper.GetDocuments()
.Path("/%", PathTypeEnum.Children)
//.ExcludePath("/Products/Sale", PathTypeEnum.Section)
.OnSite("Westkystar")
.Columns("DocumentName")
.Culture("en-us")
.toList();//Added This
return View(pg);
then in your view do this:
@model List<TreeNode>
@foreach(var page in Model)
{
<p>@page.DocumentName</p>
}
If you really want to use the viewbag, I think you need to cast it in the foreach:
@foreach(var page in pages as List<TreeNode>)