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 trialLei Lydle
Courses Plus Student 8,667 PointsASP.NET MVC Code Challenge issue
I cannot seem to get past this step. I believe the code is correct - please help.
Just so you know it was ViewBag.PageTitle = "Video Game Detail";
I have tried all of the following for this line:
@{ ViewBag.PageTitle = Model.DisplayText; }
@{ ViewBag.PageTitle = Model.Title; }
@{ ViewBag.Title = Model.DisplayText; }
@{ ViewBag.Title = Model.Title; }
I get the error for all of the above options. In the preceding instructional video the correct code looked like this:
@{ Layout = "~/Views/Shared/_Layout.cshtml"; ViewBag.Title = Model.DisplayText;
}
Challenge Task 2 of 2
Update the Detail.cshtml view to be a strongly typed view. Add a model directive to strongly type the view using the Treehouse.Models.VideoGame data model type. Replace the ViewBag Title, Description, and Characters property references with the respective Model properties.
Bummer! Did you remove the 'ViewBag.Title' property assignment to 'Video Game Detail'?
Here's is what I have...
@model Treehouse.Models.VideoGame
@{ ViewBag.Title = Model.DisplayText; }
<h1>@Model.Title</h1>
<h5>Description:</h5> <div>@Model.Description</div>
<h5>Characters:</h5> <div> <ul> @foreach (var character in Model.Characters) { <li>@character</li> } </ul> </div>
Thanks for any help!
2 Answers
James Churchill
Treehouse TeacherLei,
The code challenge is just expecting you to add a "@model" directive and update the various places where the ViewBag property values are being written to the view.
This bit at the top of the view should not be changed.
@{
ViewBag.PageTitle = "Video Game Detail";
}
Sorry for the confusing instructions.
Thanks, James
Jason Giese
15,891 Points@James Churchill, I had the same issue, I had removed the ViewBag for that screen. Appreciate the help!
James Churchill
Treehouse TeacherYou're welcome!
Luca Mori
2,969 PointsSame here, Thanks guys.