Chapter 3

Views

What's In This Chapter?

  • The purpose of views
  • Specifying a view
  • All about strongly typed views
  • Understanding view models
  • Adding a view
  • Using Razor
  • Specifying a partial view

Developers spend a lot of time focusing on crafting well-factored controllers and model objects — and for good reason, because clean, well-written code in these areas forms the basis of a maintainable web application.

But when a user visits your web application in a browser, none of that work is visible. A user's first impression and entire interaction with your application starts with the view.

The view is effectively your application's ambassador to the user — representing your application to the user and providing the basis on which the application is first judged.

Obviously, if the rest of your application is buggy, no amount of spit and polish on the view will make up for the application's shortcomings. Likewise, build an ugly and hard-to-use view, and many users will not give your application a chance to prove just how feature-rich and bug-free it may well be.

In this chapter, we won't show you how to make a pretty view. Visual design is a separate concern from rendering content, although clean markup can make your designer's life a lot easier. Instead, we will demonstrate how views work in ASP.NET MVC and what their responsibilities are, and provide you with the tools to build views that your application will be proud to wear.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset