Code Monkey home page Code Monkey logo

dotnetdockergettingstarted's Introduction

Get Started with ASP.NET Core

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.

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

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

  2. Download the sample and unzip it.

  3. Restore the packages

dotnet restore

  1. Update the code in Startup.cs to return a message of your choice
public class Startup
{
    public void Configure(IApplicationBuilder app)
    {
        app.Run(context =>
        {
            return context.Response.WriteAsync("Hello from ASP.NET Core!");
        });
    }
}
  1. Run the app (the dotnet run command will build the app when it's out of date)

dotnet run

  1. Browse to http://localhost:5000

Hello world output

  1. Press Ctrl+C to stop the app

Now let's enable support for static files.

  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!");
        });
    }
}
  1. Add a wwwroot folder with an index.html file
<!DOCTYPE html>
<html>
<body>
    <h1>Static file from ASP.NET Core!</h1>
</body>
</html>
  1. Build and run the app

dotnet run

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

Static file output

  1. Build the Docker image

./build.sh

dotnetdockergettingstarted's People

Contributors

carljmosca avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.