zoukankan      html  css  js  c++  java
  • ASP.NET MVC 3 (Intro to ASP.NET MVC 3) (1/9)

    This tutorial will teach you the basics of building an ASP.NET MVC Web application using Microsoft Visual Web Developer Express, which is a free version of Microsoft Visual Studio. Before you start, make sure you have the prerequisites listed above installed using the Web Platform Installer.

    You'll make your first ASP.NET MVC Web application using Visual Web Developer 2010 Express and SQL Server Express. We'll make a little movie list application that will let us create and list movies.

    A Visual Web Developer project with C# source code is available to accompany this topic. Download the C# version here. If you prefer Visual Basic, switch to the Visual Basic version of this tutorial.

    What You'll Build

    You'll implement a simple Movie listing application. Below are two screen-shots of the application you’ll build. It includes a page that displays a list of Movies from a database:

    MoviesWithVariousSm

    And you'll have a Create form so you can add movies to the list.

    CreateFormSo

    Skills You'll Learn

    Here's what you'll learn:

    • How to create a new ASP.NET MVC project.
    • How to create a new database using the Entity Framework code-first paradigm.
    • How to create ASP.NET MVC controllers and views.
    • How to retrieve and display data.
    • How to edit data and enable data validation.

    Getting Started

    Start by running Visual Web Developer 2010 Express ("Visual Web Developer" 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, as well as the menu you could also have used to create the project (File > New Project).

    Creating Your First Application

    You can create applications using your choice of either Visual Basic or Visual C# as the programming language. For now, select Visual C# on the left and then select ASP.NET MVC 3 Web Application. Name your project "MvcMovie" and then click OK.

    In the New ASP.NET MVC 3 Project dialog box, select Internet Application. Leave Razor as the default view engine.

    Click OK. Visual Web Developer used a default template for the ASP.NET 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 shortcut to start debugging is F5.

    F5 causes Visual Web Developer to start a development web server 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 example.com. That's because localhost always points to your own local computer, which in this case is running the application you just built. When Visual Web Developer runs a web project, a random port is used for web server. In the image below, the random port number is 43246. When you run the application, you'll probably see a different port number.

    Right out of the box this default template gives you two pages to visit and a basic login page. Let's change how this application works and learn a little bit about ASP.NET MVC in the process. Close your browser and let's change some code.

  • 相关阅读:
    用户控件包装器的设计与实现
    rskeymgmt 实用工具
    外连接(outer join)
    SQL Server中 char与varchar  
    正则表达式的优先级顺序
    正则表达式语法
    SQL各个子句: outer join,on,where,group by,having,select case子句执行
    SQL语法手册
    ACESS编程中判断空的sql语句
    Sql Server 中一个非常强大的日期格式化函数
  • 原文地址:https://www.cnblogs.com/suizhikuo/p/2381185.html
Copyright © 2011-2022 走看看