This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Note
An updated version of this tutorial is availablehere using the latest version ofVisual Studio. The new tutorial usesASP.NET Core MVC, which providesmany improvements over this tutorial.
This tutorial teaches ASP.NET Core MVC with controllers and views. Razor Pages is a new alternative in ASP.NET Core, a page-based programming model that makes building web UI easier and more productive. We recommend you try theRazor Pages tutorial before the MVC version. The Razor Pages tutorial:
This tutorial teaches you the basics of building an ASP.NET MVC 5 web app usingVisual Studio 2017. The final source code for the tutorial is located onGitHub.
This tutorial was written byScott Guthrie (twitter@scottgu ),Scott Hanselman (twitter:@shanselman ), andRick Anderson (@RickAndMSFT )
You need an Azure account to deploy this app to Azure:
Start byinstalling Visual Studio 2017. Then, open Visual Studio.
Visual Studio 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 Studio, there's a list along the bottom showing various options available to you. There's also a menu that provides another way to perform tasks in the IDE. For example, instead of selectingNew Project on theStart page, you can use the menu bar and selectFile >New Project.
On theStart page, selectNew Project. In theNew project dialog box, select theVisual C# category on the left, thenWeb, and then select theASP.NET Web Application (.NET Framework) project template. Name your project "MvcMovie" and then chooseOK.
In theNew ASP.NET Web Application dialog, chooseMVC and then chooseOK.
Visual Studio 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.
PressF5 to start debugging. When you pressF5, Visual Studio startsIIS Express and runs your web app. Visual Studio then launches a browser and opens the application's home page. Notice that the address bar of the browser sayslocalhost:port#
and not something likeexample.com
. That's becauselocalhost
always points to your own local computer, which in this case is running the application you just built. When Visual Studio runs a web project, a random port is used for the web server. In the image below, the port number is 1234. When you run the application, you'll see a different port number.
Right out of the box this default template gives youHome
,Contact
, andAbout
pages. The image below doesn't show theHome,About, andContact links. Depending on the size of your browser window, you might need to click the navigation icon to see these links.
The application also provides support to register and log in. The next step is to change how this application works and learn a little bit about ASP.NET MVC. Close the ASP.NET MVC application and let's change some code.
For a list of current tutorials, seeMVC recommended articles.
Was this page helpful?
Was this page helpful?