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.

Before you begin

Install Visual Studio

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

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

Choose your theme (optional)

This quickstart tutorial includes screenshots that use the dark theme. If you aren't using the dark theme but would like to, see the Personalize the Visual Studio IDE and Editor page to learn how.

Create a project

To start, 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. (Depending on your display settings, you might have to scroll to see it.)

    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, select ASP.NET Core 2.1 from the top drop-down menu. Next, choose Web Application, and then choose OK.

    New ASP.NET Core Web Application dialog box

    Note

    If you don't see ASP.NET Core 2.1, make sure that you are running the most recent release of Visual Studio. For more information about how to update your installation, see the Update Visual Studio to the most recent release page.

Soon after, Visual Studio opens your project file.

  1. Open Visual Studio.

  2. On the start window, choose Create a new project.

    View the 'Create a new project' window

  3. On the Create a new project window, enter or type ASP.NET in the search box. Next, choose C# from the Language list, and then choose Windows from the Platform list.

    After you apply the language and platform filters, choose the ASP.NET Core Web Application template, and then choose Next.

    Choose the C# template for the ASP.NET Core Web Application

    Note

    If you do not see the ASP.NET Core Web Application template, you can install it from the Create a new project window. In the Not finding what you're looking for? message, choose the Install more tools and features link.

    The 'Install more tools and features' link from the 'Not finding what you're looking for' message in the 'Create new project' window

    Then, in the Visual Studio Installer, choose the ASP.NET and web development workload.

    ASP.NET Core Web Application workload in the Visual Studio Installer

    After that, choose the Modify button in the Visual Studio Installer. You might be prompted to save your work; if so, do so. Next, choose Continue to install the workload. Then, return to step 2 in this "Create a project" procedure.

  4. In the Configure your new project window, type or enter HelloWorld in the Project name box. Then, choose Create.

    in the 'Configure your new project' window, name your project 'HelloWorld'

  5. In the Create a new ASP.NET Core Web Application window, verify that ASP.NET Core 2.1 appears in the top drop-down menu. Then, choose Web Application, which includes example Razor Pages. Next, choose Create.

    The 'Create a new ASP.NET Core Web Application' window

    Visual Studio opens your new project.

Create and run 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, which runs in a web browser.

    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 a web browser.)

    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

  5. Choose IIS Express or press Ctrl+F5 to run the app and open it in a web browser.

    Select the IIS Express button in Visual Studio

    Note

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

  6. In the web browser, verify that the About page includes your updated text.

    View the updated About page that includes the changes you made

  7. Close the web browser.

Review your work

View the following animation to check the work that you completed in the previous section.

View the animated .gif file that shows how to create and run a simple C# ASP.NET Core web app in Visual Studio

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