Microsoft Connect(); 2018
Watch now to get the latest updates on Azure and Visual Studio from the comfort of your favorite chair.
Watch on-demand >

ASP.NET Tutorial - Hello World in 10 minutes

  1. Install the .NET SDK

    To start building .NET apps you just need to download and install the .NET SDK (Software Development Kit).

  2. Create your app

    Open a new command prompt and run the following commands:

    dotnet new webApp -o myWebApp
    cd myWebApp

    The dotnet command creates a new application of type webApp for you. The -o parameter creates a directory named myWebApp where your app is stored, and populates it with the required files. The cd myWebApp command puts you into the newly created app directory.

    Several files were created in the myWebApp directory, to give you a simple web application that is ready to run. Startup.cs contains all the settings and configuration. The myWebApp/Pages directory contains some web pages for the application.

  3. HTTPS development certificate

    In your command prompt, run the following command:

    dotnet dev-certs https --trust

    Your operating system may prompt to check if you agree to trust the development certificate. Follow the prompts if you agree.

    This certificate allows you web app to run on HTTPS while you are developing on your machine.

  4. Run your app

    In your command prompt, run the following command:

    dotnet run

    Once the command completes, browse to https://localhost:5001

    The home page of your site contains some placeholder content about ASP.NET.

    Congratulations, you've built and run your first .NET web app!

  5. Write some code

    Open Pages/Index.cshtml in any text editor and add the following code above the first <div> tag in the file:

    <h1>Hello, world!</h1>
    <h2>The time on the server is @DateTime.Now</h2>

    Refresh the browser to see the change:

    When the page is refreshed, the new content you just added will appear at the top of the page.

  6. Get an editor

    Visual Studio is a fully-featured integrated development environment (IDE) for developing .NET apps on Windows.

    Download Visual Studio

    Select the ASP.NET and web development workload during installation.

  7. Keep learning

    Now that you've got the basics, continue building your first ASP.NET app with Razor Pages.