O'Reilly logo

Microsoft Visual Studio 2015 Unleashed, Third Edition by Mike Snell, Lars Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required