INTRODUCING IN ASP.NET CORE WEB APPLICATIONS
In this chapter you will find articles on what a web server (HTTP web server) is, how to create a simple web server, and how to create a web application. What is a web service and an example of creating a web service. You will also find articles about Web Api services that are simple and those that read data from the database, e.g. SQL Server Database. Through the example you can learn how to create a Web Api with a controller and a model.
What is web server?
It is any application or process that can communicate with a web browser (client).
If using a Web client in this case a browser (eg Crome) and in its address bar we type a URL address e.g. http // localhost: 5000 and if there is an application or process that will respond to such a request and send back (to the browser) a message in response, we can say that it is a web server (http server). The location of that application can be anywhere on the web, ie. it can be on the same computer or on a remote computer, laptop, mobile phone or real web server, it is important that it (web application) can communicate with the web browser and respond to its requests. In order to create a website or application, we first need to download and install asp.net core on a local computer. It can be downloaded from the website: https://dotnet.microsoft.com/en-us/download/dotnet |
|
What is needed is to download some of the offered, best recommended versions of the asp.net core framework from this website. It should be noted that after version 3.1, the "core" in the name was removed, but it is still the same technology.
Asp.net core is multiplatform, unlike asp.net, which can be used to create web applications only on the Windows operating system.
The next thing that is desirable, but not necessary, is the installation of some of the auxiliary tools, e.g. "VS code" or "Microsoft Visual Studio".
VS Code will be used in this tutorial. It can be downloaded from the following link:
code.visualstudio.com/download
In order to create an application using the dotnet core, let's first create an application folder, e.g. on the path:
c://aspdotnetcore/Products
Asp.net core is multiplatform, unlike asp.net, which can be used to create web applications only on the Windows operating system.
The next thing that is desirable, but not necessary, is the installation of some of the auxiliary tools, e.g. "VS code" or "Microsoft Visual Studio".
VS Code will be used in this tutorial. It can be downloaded from the following link:
code.visualstudio.com/download
In order to create an application using the dotnet core, let's first create an application folder, e.g. on the path:
c://aspdotnetcore/Products
To check which dotnet core version is installed:
The figure shows that version 5.0 is installed, but in case none of them need to install one of the asp.net core versions.
To create a website called Products, type in the folder of the same name:
dotnet new web which can be seen in the following image:
To create a website called Products, type in the folder of the same name:
dotnet new web which can be seen in the following image:
The structure of the required files within the application's root folder will be created:
In order to start the newly created application, it is necessary to type in the command prompt:
dotnet run ,
as can be seen in the following figure:
dotnet run ,
as can be seen in the following figure:
To change the code within the application, you must first turn off the application by typing ctrl + C, and then run VS Code, using the command:
code .
After starting the application, the content of the project will be visible in VS Code, as shown in the figure:
In order to be e.g. display the system time instead of the "Hello World" message, you need to change the MapGet method:
After the call: http://localhost:5000/time