.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.
Need Some .NET Help?
Search fiverr for freelance .NET developers.
Follow me for updates
When I'm not coding...
Me and Tina are on a motorcycle adventure around Australia.
Come along for the ride!
More .NET Posts
- Deploy .NET 6 API to AWS Lambda with SQL Database (RDS) and Email (SES)
- .NET 7.0 + Postgres CRUD API with Angular Front End App
- .NET 7.0 + MySQL - Connect to MySQL Database with Dapper in C# and ASP.NET Core
- MySQL + Dapper - Create database if it doesn't exist on startup with C# and ASP.NET Core
- .NET 7.0 + Dapper + MySQL - CRUD API Tutorial in ASP.NET Core
- Postgres CRUD Operations in C# with Dapper Repository
- .NET 7.0 + C# - JWT Authentication Tutorial without ASP.NET Core Identity
- .NET 7.0 + Postgres - Connect to PostgreSQL Database with Dapper in C# and ASP.NET Core
- Postgres + Dapper - Create database if it doesn't exist on startup with C# and ASP.NET Core
- .NET 7.0 + Dapper + PostgreSQL - CRUD API Tutorial in ASP.NET Core
- .NET + VS Code + XUnit - Setup Unit Testing & Code Coverage in ASP.NET Core
- SqlClient.SqlException - The certificate chain was issued by an authority that is not trusted
- .NET 7.0 + Dapper - Connect to MS SQL Server Database in ASP.NET Core
- .NET 7.0 + Dapper + MS SQL Server - CRUD API Tutorial in ASP.NET Core
- Dapper + SQL Server - Create database if it doesn't exist on startup in ASP.NET Core
- .NET 7.0 + Dapper - Connect to SQLite Database in ASP.NET Core
- .NET 7.0 + Dapper + SQLite - CRUD API Tutorial in ASP.NET Core
- C# + .NET 7.0 - Serialize (Convert) Enum to String in API Response
- .NET 7.0 + Dapper - Create Database Tables on Startup in ASP.NET Core
- React 18 Authentication with .NET 6.0 (ASP.NET Core) JWT API
- Angular 14 Authentication with .NET 6.0 (ASP.NET Core) JWT API
- Vue 3 Authentication with .NET 6.0 (ASP.NET Core) JWT API
- C# + RestSharp - Add Bearer Token Authorization Header to HTTP Request in .NET
- C# + RestSharp - HTTP PUT Request Examples in .NET
- C# + RestSharp - HTTP DELETE Request Examples in .NET
- C# + RestSharp - HTTP GET Request Examples in .NET
- C# + RestSharp - POST a JSON Object to an API in .NET
- C# + RestSharp - HTTP POST Request Examples in .NET
- .NET 7.0 + RestSharp - Deserialize Dynamic JSON Response from HTTP Request
- .NET 7.0 - Create a Base Controller in .NET
- .NET 7.0 Auth - Sign & Validate JWT Without Core Identity
- .NET 7.0 - Create Custom AuthorizeAttribute and AllowAnonymous Attribute
- .NET + Entity Framework - Fix for Non-nullable property '...' must contain a non-null value in EF DbContext
- .NET 7.0 - Facebook Authentication API Tutorial with Example
- .NET 6.0 - Apply Authorize Attribute to All Controllers
- .NET 6.0 - Connect to InMemory Database with Entity Framework Core
- Angular + .NET - Connect an Angular App to a .NET API
- .NET 6.0 - Connect to SQLite Database with Entity Framework Core
- .NET 6.0 - Connect to PostgreSQL Database with Entity Framework Core
- .NET 6.0 - Connect to MySQL Database with Entity Framework Core
- .NET 6.0 - Connect to SQL Server with Entity Framework Core
- .NET 6.0 - CRUD API Example and Tutorial
- .NET 6.0 - Send an Email via SMTP with MailKit
- .NET 6.0 - Boilerplate API Tutorial with Email Sign Up, Verification, Authentication & Forgot Password
- .NET 6.0 - Role Based Authorization Tutorial with Example API
- .NET 6.0 - Minimal API Tutorial and Example
- .NET 6.0 - Execute EF Database Migrations from Code on Startup
- .NET 6.0 - Database Migrations to Different DB Per Environment (SQLite in Dev, SQL Server in Prod)
- .NET 6.0 - JWT Authentication with Refresh Tokens Tutorial with Example API
- .NET 6.0 - Create and Validate JWT Tokens + Use Custom JWT Middleware
- .NET 6.0 - Global Error Handler Tutorial with Example
- .NET 6.0 - Hash and Verify Passwords with BCrypt
- .NET 6.0 - User Registration and Login Tutorial with Example API
- .NET 6.0 - Basic Authentication Tutorial with Example API
- .NET 6.0 - JWT Authentication Tutorial with Example API
- .NET 5.0 - Connect to MySQL Database with Entity Framework Core
- .NET 5.0 - Connect to SQL Server with Entity Framework Core
- .NET - Return Enum as String from API
- .NET - Startup Class in a Nutshell
- .NET - Program Class and Main Method in a Nutshell
- .NET + MSBuild - C# Project File (.csproj) in a Nutshell
- .NET 5.0 - CRUD API Example and Tutorial
- .NET 5.0 - Send an Email via SMTP with MailKit
- .NET 5.0 - Boilerplate API with Email Sign Up, Verification, Authentication & Forgot Password
- .NET 5.0 - Role Based Authorization Tutorial with Example API
- .NET 5.0 - Bare Bones API Tutorial
- VS Code + .NET - Debug a .NET Web App in Visual Studio Code
- .NET 5.0 API - JWT Authentication with Refresh Tokens
- .NET 5.0 - Automatic Entity Framework Migrations to SQL Database on Startup
- .NET 5.0 - Entity Framework Migrations for Multiple Databases (SQLite and SQL Server)
- .NET 5.0 - Create and Validate JWT Tokens + Use Custom JWT Middleware
- .NET 5.0 - Global Error Handler Tutorial
- .NET 5.0 - Hash and Verify Passwords with BCrypt
- .NET 5.0 API - Allow CORS requests from any origin and with credentials
- .NET 5.0 - Simple API for Authentication, Registration and User Management
- .NET 5.0 - Basic Authentication Tutorial with Example API
- .NET 5.0 - JWT Authentication Tutorial with Example API