Defining a typed view

To improve the IntelliSense when writing a view, you can define the type the view can expect using a @model directive at the top.

In the Views\Home folder, open Index.cshtml view, and add a statement to set the model type to use the HomeIndexViewModel as the first line of the file, as shown in the following code:

@model Packt.CS7.HomeIndexViewModel 

Now, whenever we type Model in this view, the IntelliSense will know the correct type and will provide IntelliSense.

To declare the type for the model, use @model (with lowercase m).

To interact with the model, use @Model (with uppercase M).

In Index.cshtml, modify the carousel <div> element, delete all of the other <div> elements, and replace them with the new markup to ...

Get C# 7 and .NET: Designing Modern Cross-platform Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.