Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEllis Garaudy
Courses Plus Student 9,705 PointsObject reference not set to an instance of an Object. Line 5: ViewBag.Title = Model.DisplayText;
Hi getting an error in post-build with the page title.
Details.cshtml ViewBag.Title = Model.DisplayText;
ComicBook.cs public string DisplayText { get { return SeriesTitle + " #" + IssueNumber; } }
1 Answer
James Churchill
Treehouse TeacherEllis,
As Steven mentioned, it's difficult to know what is the cause of the error without having more context. That being said, I would double check if the controller action method (that's associated with this view) is passing a data model object instance to the View
method call.
Thanks ~James
Steven Parker
231,269 PointsSteven Parker
231,269 PointsI'd need to see more of the code to determine what's causing the error. Clearly, either "ViewBag" or "Model" is null at line 5, but the reason for it cannot be seen here.