This course will be retired on July 14, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Adding a View 4:03
- Adding a View Review 5 questions
- Using Razor for View Layout 5:30
- Using the Razor Syntax 1 objective
- Displaying a List with Razor 4:16
- Displaying a List of Values 1 objective
- Setting Data in the Controller 5:51
- Using ViewBag 2 objectives
- Adding Design Files 4:41
- View Layouts 5:42
- Section Review 5 questions

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
Let’s see how we can use the Razor syntax to improve our view layout.
Follow Along
To follow along commiting your changes to this course, you'll need to fork the aspnet-comic-book-gallery repo. Then you can clone, commit, and push your changes to your fork like this:
git clone <your-fork>
cd aspnet-comic-book-gallery
git checkout tags/v3.2 -b using-razor-for-view-layout
Code
Here’s the comic book description and artist information.
<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>
"Script: Dan Slott",
"Pencils: Humberto Ramos",
"Inks: Victor Olazaba",
"Colors: Edgar Delgado",
"Letters: Chris Eliopoulos"
Here’s the C# code for the comic book variables.
var seriesTitle = "The Amazing Spider-Man";
var issueNumber = 700;
var description = "<p>Final issue! Witness the final hours of Doctor Octopus' life and his one, last, great act of revenge! Even if Spider-Man survives... <strong>will Peter Parker?</strong></p>";
var artists = new string[]
{
"Script: Dan Slott",
"Pencils: Humberto Ramos",
"Inks: Victor Olazaba",
"Colors: Edgar Delgado",
"Letters: Chris Eliopoulos"
};
Additional Learning
Here’s an introduction to the Razor syntax on the official ASP.NET website.
Here’s a great blog post from Phil Haack containing a Razor syntax quick reference. Very handy!
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Evan Payne
16,564 Points1 Answer
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up