Blog

Get Started with ASP.NET

Below you will find the steps to build your first ASP.NET Core app. See Get Started with ASP.NET if you are looking to get started with ASP.NET and the .NET Framework on Windows. Learn more about the difference between ASP.NET and ASP.NET Core.

Download.NET Core
Free .NET command-line tools for Windows, Mac, and Linux

Let's start by building a simple "Hello, world!" app.

  1. 1

    Install .NET Core. See installation steps for Windows, macOS, and Linux here.

  2. 2

    Download the sample and unzip it.

  3. 3

    Restore the packages

    1. dotnet restore
  4. 4

    Update the code in Startup.cs to return a message of our choice

    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello from ASP.NET Core!");
            });
        }
    }
  5. 5

    Run the app (the dotnet run command will build the app when it's out of date)

    1. dotnet run
  6. 6

    Browse to http://localhost:5000

  7. 7

    Press Ctrl+C to stop the app

Now let's enable support for static files.

  1. 1

    Add the static file middleware in Startup.cs

    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();
    
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello from ASP.NET Core!");
            });
        }
    }
  2. 2

    Add a wwwroot folder with an index.html file

    <!DOCTYPE html>
    <html>
    <body>
        <h1>Static file from ASP.NET Core!</h1>
    </body>
    </html>
  3. 3

    Build and run the app

    1. dotnet run
  4. 4

    Browse to http://localhost:5000/index.html

  5. That’s it!

    Next up, try building your first ASP.NET Core MVC app with Visual Studio or Visual Studio Code.

    Also checkout out the docs and tutorials.