.NET - Create and Run a Simple 'Hello World' Web App
With the .NET CLI you can create a new project with the dotnet new <TEMPLATE>
command, where the TEMPLATE is the type of application you want to create. To create a .NET Web App execute the command dotnet new web --name <NAME>
, the NAME parameter sets the name of the .NET project and directory created, if omitted the name of the current directory is used.
The web
template creates a simple Hello World .NET starter web application that contains some basic configuration and a single endpoint that returns the string "Hello World!"
from the base path ("/"
).
Follow these steps to create a starter .NET web application named MyWebApp and open it in VS Code.
- Install the .NET SDK from https://dotnet.microsoft.com/download, includes the .NET runtime and CLI
- Run the command
dotnet new web --name MyWebApp
to create a new web app named MyWebApp - Navigate into the web app directory with the command
cd MyWebApp
- Start the .NET web app with the command
dotnet run
- Open the web app in a browser using the URL from the command output (Now listening on: http://localhost:[PORT NUMBER])
For more info on the dotnet new
command see https://docs.microsoft.com/dotnet/core/tools/dotnet-new.
Subscribe or Follow Me For Updates
Subscribe to my YouTube channel or follow me on Twitter, Facebook or GitHub to be notified when I post new content.
- Subscribe on YouTube at https://www.youtube.com/JasonWatmore
- Follow me on Twitter at https://twitter.com/jason_watmore
- Follow me on Facebook at https://www.facebook.com/JasonWatmoreBlog
- Follow me on GitHub at https://github.com/cornflourblue
- Feed formats available: RSS, Atom, JSON
Other than coding...
I'm currently attempting to travel around Australia by motorcycle with my wife Tina on a pair of Royal Enfield Himalayans. You can follow our adventures on YouTube, Instagram and Facebook.
- Subscribe on YouTube at https://www.youtube.com/TinaAndJason
- Follow us on Instagram at https://www.instagram.com/tinaandjason
- Follow us on Facebook at https://www.facebook.com/TinaAndJasonVlog
- Visit our website at https://tinaandjason.com.au
Need Some .NET Help?
Search fiverr to find help quickly from experienced .NET developers.