This is my controller fetching a list of blogpost and stores the in listOfBlogposts:
//BlogHome
public ActionResult BlogHome(string pageId, string viewName)
{
var page = RavenSession.Load<ContentPage>(pageId) as BlogListContentPage;
var listOfAllBlogPosts =
RavenSession.Query<ContentPage>().Where(o => o.Template.Action.Equals("SingleBlogPost")).ToList();
page.SingleBlogPostsContentPages = listOfAllBlogPosts;
return View(viewName, page);
}
The class containing the list:
public class BlogListContentPage : ContentPage
{
public List<ContentPage> SingleBlogPostsContentPages { get; set; }
}
When the debugger comes to this line:
page.SingleBlogPostsContentPages = listOfAllBlogPosts;
I get the error:
Object reference not set to an instance of an object
This is a common error for me and I do not know how to solve it..Maybe its more complicated when you, like ib this example, use inheritance..