Quickstart: Use Visual Studio to create your first ASP.NET Core web app

In this 5-10 minute introduction to how to use Visual Studio, you'll create a simple "Hello World" web app by using an ASP.NET project template and the C# programming language.

If you haven't already installed Visual Studio, go to the Visual Studio downloads page to install it for free.

Create a project

First, you'll create an ASP.NET Core web application project. The project type comes with all template files to create a web app, before you've even added anything!

  1. Open Visual Studio 2017.

  2. From the top menu bar, choose File > New > Project.

  3. In the left pane of the New Project dialog box, expand Visual C#, and then choose .NET Core. In the middle pane, choose ASP.NET Core Web Application. Then, name your file HelloWorld and choose OK.

    Create the new ASP.NET Core Web Application project for C#

    Note

    If you don't see the .NET Core project template category, choose the Open Visual Studio Installer link in the left pane.

    Open Visual Studio Installer from the new project dialog box

    The Visual Studio Installer launches. Choose the ASP.NET and web development workload, and then choose Modify.

    ASP.NET workload in VS Installer

    (You might have to close Visual Studio before you can continue installing the new workload.)

  4. In the New ASP.NET Core Web Application dialog box, verify that ASP.NET Core 2.0 appears in the top drop-down menu. Then, choose Web Application and choose OK.

    New ASP.NET Core Web Application dialog box

Soon after, Visual Studio opens your project file.

Create the app

  1. In the Solution Explorer, expand the Pages folder, and then choose About.cshtml.

    Choose the About.cshtml file from the Solution Explorer

    This file corresponds to a page that's named About in the web app.

    The About page in the web app

    In the editor, you'll see HTML code for the "additional information" area of the About page.

    The HTML code for the additional information area in the Visual Studio editor

  2. Change the "additional information" text to read "Hello World!".

    Change the default The HTML code for the additional information area in the Visual Studio editor

  3. In the Solution Explorer, expand About.cshtml, and then choose About.cshtml.cs. (This file also corresponds with the About page in your web app.)

    Choose the About.cshtml file from the Solution Explorer

    In the editor, you'll see C# code that includes text for the "application description" area of the About page.

    The C# code for the application description area in the Visual Studio editor

  4. Change the "application description" message text to read "What's my message?".

    Change the default message text for the application description area in the Visual Studio editor

Run the app

  1. Press Ctrl+F5 to run the app and open it in a web browser.

    Note

    If you get an error message that says, Unable to connect to web server 'IIS Express', close Visual Studio and then open it by using the Run as administrator option from the right-click or context menu. Then, run the application again.

  2. At the top of the web page, choose About.

    Select About from the web page

  3. View the updated text that you added to the About page.

    View the updated About page that includes the text that you added

  4. Close the web browser.

Congratulations on completing this Quickstart! We hope you learned a little bit about C#, ASP.NET Core, and the Visual Studio IDE (integrated development environment).

Next steps

To learn more, continue with the following tutorial:

See also

Publish your web app to Azure App Service by using Visual Studio