Example: bachelor of science

Intro to ASPNET MVC 4 with Visual Studio 2011 Beta

IntrVisuRick A Summaapplicatversion oCategorApplies Source: E-book 115 pag ro toual SAndersory: This tutoion using Mof Microsofry: Step-Byto: sipublicatioes o ASPS tudioon and Sorial will teMicrosoft Vift Visual Stu-Step ET MVC 4 Bte (link to son date: Ma (BeScott Haach you theisual Studioudio. eta, Visual source contay 2012 T MVeta)anselmae basics of o 11 ExpressStudio 11 Btent) VC 4 wan building ans Beta for WBeta with n MWeb, which MVC Web is a free Copyright 2012 by Microsoft Corporation All rights reserved.

A Visual Web Developer project with C# source code is available to accompany this topic. Download the C# version. What You'll Build . You'll implement a simple movie-listing application that supports creating, editing, searching and listing movies from a database. Below are two screenshots of the application you’ll build.

Tags:

  Visual

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Transcription of Intro to ASPNET MVC 4 with Visual Studio 2011 Beta

1 IntrVisuRick A Summaapplicatversion oCategorApplies Source: E-book 115 pag ro toual SAndersory: This tutoion using Mof Microsofry: Step-Byto: sipublicatioes o ASPS tudioon and Sorial will teMicrosoft Vift Visual Stu-Step ET MVC 4 Bte (link to son date: Ma (BeScott Haach you theisual Studioudio. eta, Visual source contay 2012 T MVeta)anselmae basics of o 11 ExpressStudio 11 Btent) VC 4 wan building ans Beta for WBeta with n MWeb, which MVC Web is a free Copyright 2012 by Microsoft Corporation All rights reserved.

2 No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Microsoft and the trademarks listed at are trademarks of the Microsoft group of companies. All other marks are property of their respective owners. The example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, email address, logo, person, place, or event is intended or should be inferred.

3 This book expresses the author s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties. Neither the authors, Microsoft Corporation, nor its resellers, or distributors will be held liable for any damages caused or alleged to be caused either directly or indirectly by this book. Contents Getting Started .. 3 What You'll Build .. 3 Skills You'll Learn .. 5 Getting Started .. 6 Creating Your First Application .. 7 Adding a Controller .. 13 Adding a View .. 20 Changing Views and Layout Pages.

4 25 Passing Data from the Controller to the View .. 31 Adding a Model .. 37 Adding Model 37 Creating a Connection String and Working with SQL Server LocalDB .. 41 Accessing Your Model's Data from a Controller .. 43 Creating a Movie .. 46 Examining the Generated 48 Strongly Typed Models and the @model Keyword .. 49 Working with SQL Server LocalDB .. 53 Examining the Edit Methods and Edit View .. 58 Processing the POST Request .. 65 Adding a Search Method and Search View .. 67 Displaying the SearchIndex Form .. 67 Adding Search by Genre.

5 77 Adding Markup to the SearchIndex View to Support Search by Genre .. 79 Adding a New Field to the Movie Model and Table .. 80 Adding a Rating Property to the Movie Model .. 80 Managing Model and Database Schema Differences .. 82 Automatically Re-Creating the Database on Model Changes .. 85 Adding Validation to the Model .. 95 Keeping Things DRY .. 95 Adding Validation Rules to the Movie Model .. 95 Validation Error UI in MVC .. 97 How Validation Occurs in the Create View and Create Action Method .. 100 Adding Formatting to the Movie 108 Examining the Details and Delete Methods.

6 111 Examining the Details and Delete Methods .. 111 Wrapping Up .. 113 Getting Started By Rick Anderson and Scott Hanselman This tutorial will teach you the basics of building an MVC Web application using Microsoft Visual Studio 11 Express Beta for Web, which is a free version of Microsoft Visual Studio . Before you start, make sure you've installed the prerequisites listed below. You can install all of them by clicking the following link: Web Platform Installer. If you're using Visual Studio 11 Beta instead of Visual Studio 11 Express Beta for Web , install the prerequisites by clicking the following link: Web Platform Installer A Visual Web Developer project with C# source code is available to accompany this topic.

7 Download the C# version. What You'll Build You'll implement a simple movie-listing application that supports creating, editing, searching and listing movies from a database. Below are two screenshots of the application you ll build. It includes a page that displays a list of movies from a database: The application also lets you add, edit, and delete movies, as well as see details about individual ones. All data-entry scenarios include validation to ensure that the data stored in the database is correct. Skills You'll Learn Here's what you'll learn: How to create a new MVC project.

8 How to create MVC controllers and views. How to create a new database using the Entity Framework Code First paradigm. How to retrieve and display data. How to edit data and enable data validation. Getting Started Start by running Visual Web Developer 11 Express Beta(" Visual Web Developer" or VWD for short) and select New Project from the Start page. Visual Web Developer is an IDE, or integrated development environment. Just like you use Microsoft Word to write documents, you'll use an IDE to create applications. In Visual Web Developer there's a toolbar along the top showing various options available to you.

9 There's also a menu that provides another way to perform tasks in the IDE. (For example, instead of selecting New Project from the Start page, you can use the menu and select File>New Project.) Creating Your First Application You can create applications using either Visual Basic or Visual C# as the programming language. Select Visual C# on the left and then select MVC 4 Web Application. Name your project "MvcMovie" and then click OK. In the New MVC 4 Project dialog box, select Internet Application. LeaveRazor as the default view engine.

10 Click OK. Visual Web Developer used a default template for the MVC project you just created, so you have a working application right now without doing anything! This is a simple "Hello World!" project, and it's a good place to start your application. From the Debug menu, select Start Debugging. Notice that the keyboard shortcut to start debugging is F5. F5 causes Visual Web Developer to start IIS Express and run your web application. Visual Web Developer then launches a browser and opens the application's home page. Notice that the address bar of the browser says localhost and not something like That's becauselocalhost always points to your own local computer, which in this case is running the application you just built.


Related search queries