How to create a Hello World web app using ASP.NET Core?
This is tutorial will help you to create a Hello World web app using ASP.NET Core. If you are looking for a tutorial for “How to create a Hello World web app using ASP.NET Core?” then this will help you a lot.
IF you don’t have .NET installed in your system then you first need to install .NET SDK (Software Development Kit). Download .NET SDK from here => Link
Check everything installed correctly
Once you’ve installed it, open a new command prompt and run the following command:
> dotnet
If the installation succeeded, you should see an output similar to the following:
Usage: dotnet [options] Usage: dotnet [path-to-application] Options: -h|--help Display help. --info Display .NET information. --list-sdks Display the installed SDKs. --list-runtimes Display the installed runtimes. path-to-application: The path to an application .dll file to execute.
Now it’s time to create the first new web app.
Create your web app
In your command prompt, run the following command to create your app:
> dotnet new webApp -o HelloWorldWebApp --no-https
Then, navigate to the new directory created by the previous command:
> cd HelloWorldWebApp
What do these commands mean?
The dotnet new
the command creates a new application.
- The
webApp
parameter selects what template to use when creating your app. - The
-o
parameter creates a directory namedHelloWorldWebApp
where your app is stored. - The
--no-https
flag specifies not to enable HTTPS.
The cd HelloWorldWebAppthe
command puts you into the newly created app directory.
What files were created?
Several files were created in the HelloWorldWebApp
directory to give you a simple web application that is ready to run.
Startup.cs
contains the app startup code and middleware configuration.- The
HelloWorldWebApp/Pages
directory contains some example web pages for the application. HelloWorldWebApp.csproj
defines what libraries are referenced etc.
It’s time to run your app
In your command prompt, run the following command:
> dotnet watch run
The dotnet watch run
the command will build and start the app, and then rebuild and restart the app whenever you make code changes. You can stop the app at any time by selecting Ctrl+C.
Wait for the app to display that it’s listening on http://localhost:5000
and for the browser to launch at that address.