Lesson 1 - Introduction to ASP.NET
Welcome to the first lesson of our ASP.NET website development course. Today, we're gonna introduce the technology and explain its core principles.
ASP.NET is a web framework. In short, it's a set of libraries that allows building web applications in the C# language. The libraries include complete solutions to many of the basic issues that arise in web development. These are, for example, security, user authentication, working with the database, form handling, and so on. ASP is not a programming language, we'll program in C# and so you'll need basic knowledge of this language. Theoretically, it's also possible to program in Visual Basic, but almost no one does that If you don't know C#, it's not a problem, you can find tutorials for beginners in the C# .NET section then you can come back here. You also need at least a basic knowledge of HTML, which you can get by reading several HTML tutorials. Because the web applications become more and more popular and replace the desktop applications, most companies want their C# programmers to also know the ASP.NET framework. It definitely pays off to know something about this technology.
What can be created with ASP.NET?
Completely everything. ASP.NET is suitable for both small personal websites and large projects, whether corporate or web portals. It's a minority technology, of course, because of the license reasons. Although you can create a website in the free edition of Visual Studio, there aren't that many web hosting companies supporting ASP.NET, especially the free ones. When we take all the web apps and compare how many of them run on ASP.NET compared to competitive PHP, which is an open technology, it won't be a big number. However, if we only consider large projects such as stackoverflow or w3schools, relatively many of them are running on ASP.NET. It's also popular in corporates.
ASP.NET Core Principles
The technology is based on the client-server architecture. An ASP.NET application is therefore a program which output is an HTML page. ASP.NET runs on the server side. In order to better understand how ASP.NET works, let's show ordinary static websites first.
Static websites (without ASP.NET)
You've already seen such a website somewhere, for sure. HTML pages are simply stored on the server. Once the client (the user with the browser) sends a request to the server, the server simply returns those pages that it has stored.
Visually, the communication looks like this:
Dynamic websites (with ASP.NET)
The static websites are difficult to maintain and have great limitations. That's why server languages were created, allowing the HTML page to be modified even before it's sent to the client. Like that, you can create active elements such as discussion forums, user accounts, content management systems, and so on.
So ASP.NET runs on the server-side, it generates a website
according to the request from the client and sends it to the client. They see
only the resulting HTML, where is no sign of ASP.NET (except that the website
.aspx extension and not
Visually, the situation would look like this:
There are enormous differences between C# and competing PHP. While PHP is a dynamic language, C# is strongly typed. As it turned out, such a language can be also useful for the web, but if you come from PHP, it may be unusual. The great advantage is the possibility to use the .NET framework that can be helpful on the server-side because it contains many useful libraries and functions. Just to clarify, ASP.NET is one of the .NET framework components.
ASP.NET runs on the IIS server (Internet Information Services) and can theoretically run even on the Apache web server as a module (like PHP). We'll get this server installed with the full version of Visual Studio or the free Visual Studio community version so we can simply debug websites on our computer. As for free hosting companies for testing ASP.NET websites, it's worth trying e.g. https://www.smarterasp.net. For more serious projects, you need to buy a web hosting, but this applies for all technologies.
WebForms, MVC, and Core
Microsoft offers us multiple ways to create websites. WebForms, which is historically the oldest, is now relatively uninteresting. Their successor is ASP.NET MVC, and it's currently being replaced by ASP.NET Core technology, which is, fortunately, very similar.
WebForms was an attempt to migrate WinForms (i.e. standard form/windows applications as we know them from the desktop) to the web. The core idea is to compose a form simply from various controls from a toolbox (buttons, labels, textboxes, etc.) using a designer, and then assign events to these controls. The application behaves like a desktop app from the outside, but there's more complex logic in the background. The goal of simulating a desktop application on the web is quite difficult because the HTTP protocol is stateless. The advantage of WebForms is the tremendous speed of creating applications, especially those with plenty of forms. The disadvantage is more complicated architecture and the problem of doing anything "different" or cooperate with other technologies. Because of these issues, WebForms is not being used anymore.
MVC is a newer concept and works in a different way. It splits the web application into 3 types of components: Models, Views, and Controllers. The controller is a controlling component that receives data from the user and communicates with the model. The model contains logic, works with the database, and so on. Data from the model are passed by the controller to the view. The view is basically a template to which the data are inserted into and the resulting HTML page is created. Simply put, the goal of this concept is to make the web architecture clearer and divide it into 2 parts - Logic and Output. The controller then connects these two parts.
As Microsoft is trying to contribute to the open source community, after opening the C# language and .NET Framework, it was only a matter of time before the company decided to allow ASP.NET to be used outside of the Windows operating system as well. The main difference between ASP.NET Core and ASP.NET MVC is that we upload the ASP.NET framework itself together with our application to the server, therefore it doesn't have to be installed on the server. So we can upload our application anywhere, even if there's no Windows or ASP.NET environment. To make it a little more difficult, besides the MVC approach, Core also brings other ways to create web applications. ASP.NET Core is currently being developed intensively and therefore it's certainly a technology worth learning.
So we've outlined what it's supposed to be about. In the next lesson, Introduction to ASP.NET web applications, we'll introduce the web applications to understand why they are more in demand than the desktop applications.
No one has commented yet - be the first!