DEV Community

Yash Jayesh Chauhan
Yash Jayesh Chauhan

Posted on

ASP.NET — Create your first “Hello World!” web app in 5 minutes

Alt Text

ASP.NET is an open-source web framework, created by Microsoft, for building modern web apps and services with .NET. ASP.NET is cross-platform and runs on Windows, Linux, macOS, and Docker.

Purpose

We’ll be Installing and creating our very first Hello World ASP.NET web app that displays a Hello World! message on a web page.

Prerequisites

None.
But I’ll be using Visual Studio Code. You guys can choose whatever IDE you’re comfy with.
So let’s dive into it!
Step 1: (Installation)
To start building .NET apps, download and install the .NET SDK (Software Development Kit). (Link to Download) If you’re using an older version of windows (Windows 7 / Vista / 8.1 / Server 2008 R2 / Server 2012) you need to install additional dependencies.
After successfully installing .NET SDK into the system just verify it using our command prompt by using the following command:
Alt Text
If the command runs, printing out information about how to use dotnet, then you’re good to go.

Step 2: (Create the Web app)

Open your command prompt and run the following command:
Alt Text
Alt Text
The dotnet new is the command to creates a new application. The webApp parameter selects what template to use when creating your app. The -o parameter creates a directory named TestWebApp where your app is stored and the --no-https flag specifies not to enable HTTPS.

Several files were created in the TestWebApp directory, to give you a simple web application that is ready to run.

Alt Text
Startup.cs contains all the settings and the configurations.
The TestWebApp/Pages the directory contains some example web pages for the application.
TestWebApp.csproj defines what libraries are referenced etc.

Step 3: (Run your Web App)

Alt Text

Once the command completes, browse to http://localhost:5000 ##Congratulations, you’ve built and run your first .NET web app!

Alt Text
To Edit your code:
Open Pages/Index.cshtml in any text editor and replace all of the code with the following, then save the file.
Alt Text

Re-run your app using the previous dotnet run the command that is running the site locally, then run the following command to re-launch the site:

Alt Text
Here you go!
If I have missed something, please add it so other readers can benefit from it.

Linkedin: https://www.linkedin.com/in/iyashjayesh/

Thanks for reading and keep coding 😄

Top comments (0)