Strongly Typed Views

A strongly typed view is one that is designed to work with an object from your model (or view model, as discussed later in this chapter). You create a strongly typed view by adding the @model definition at the top of your view page. For example, you would add the following line to the top of view that works with a Customer instance.

@model AspNet5Unleashed.Models.Customer

This definition at the top of your page indicates to the MVC framework that the view expects a Customer object when the controller creates it. The controller passes this model data to the view and the runtime will assign this object to the view’s @model definition. It will also post this same customer object back to your POST ...

Get Microsoft Visual Studio 2015 Unleashed, Third Edition 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.