Author: Ted Kolovos
Website: Amazing ASP.NET -
Did you ever wonder what really happens when you type a URL into your web browser and press enter? Or when you enter your credit card information to buy a product and click Complete Order?
In this introductory overview of ASP.NET I’m going to discuss about what exactly ASP.NET really is and how it works to run dynamic web applications. The purpose of this article is to give you a foundation level look at the ASP.NET web application platform and help you understand the basic core concepts of the ASP.NET runtime so that your learning can progress quickly and easily.
So what exactly is ASP.NET and what is the ASP.NET runtime?
In order to answer these two questions we have to cover some basic dynamic website concepts first.
Introduction to web servers and how your browser talks to them
On the World Wide Web, the tool that people use to navigate around and read or watch material is the Web Browser (e.g. Internet Explorer, Firefox, etc.). Web browsers understand a special tag language which is HTML. When you want to visit a website and view the material on that website, you type in the URL (unique address of the website) in your browser window and your browser visits the website.
Once you have typed in the URL and pressed Enter, your web browser starts communicating with the website across the Internet network behind the scenes. The only thing you see is maybe an hourglass or a spinning globe that indicates that something is happening. As you see that globe spinning, your web browser communicates with a special software program behind the scenes called a web server. The web server is a special software application program that is running on the Internet computer that you requested in your URL.
So if you requested a URL that looks like http://bogusinternetserver.com/mypage.html you should know that there is a remote computer on the Internet at the address bogusinternetserver.com and that remote computer is running a special program called a web server. The web server is the program that is responsible for fetching the HTML file that you requested. The web server’s job is to go fetch mypage.html or whatever you typed into your browser.
Static versus Dynamic web pages
Under normal circumstances, the web server will simply fetch the file (mypage.html) that you requested and send it to your browser. Then your browser will display the file in a viewable/readable format (with text, graphics and hyperlinks).
There are other situations however when the file being requested is not a Static file like mypage.html, but instead is a Dynamically created file (mywebpage.aspx). The web server knows that the file is dynamic based on the file extension which in this example is .aspx. When a dynamic file is requested, the web server will pass execution control over to a separate program. That separate program is the ASP.NET runtime, which is responsible for executing the C# code associated with the dynamic web page (mywebpage.aspx) and then sending the results of that web page execution back to the browser.
Comparing when HTML is created statically versus dynamically
Static web files simply contain HTML markup tags and are actual files stored on a hard drive. In contrast Dynamic web files are not really files in the traditional sense. Dynamic web files (ending in .aspx) are a combination of C# code and special ASP.NET server tags that when combined together, can be executed dynamically as the application is running to produce HTML on the fly.
The reason that programmers need dynamic web files on the Internet is so that we can write web enabled applications that do useful things for users like view their bank accounts or buy products using their credit cards. In fact, nowadays the web is filled with dynamic web applications. Every time you type a search into Google or your favorite web search, you are running a dynamic web file. These types of dynamic actions are not possible with traditional HTML tags. Dynamic web files are necessary to process input data that is entered into web page forms. Think about when you fill out your credit card information into a web form and press a Complete Order button. Once that button is clicked, there a dynamic web file that executes to actually process your order.
So what exactly is the ASP.NET runtime again?
The ASP.NET runtime is the special program that dynamically executes ASP.NET web page code and produces HTML that is sent back to the browser. Remember that a web browser only understands HTML, so the end result of a dynamic web page execution must always be HTML. One of the real powers of the ASP.NET platform is that as a programmer you can concentrate on implementing your business requirements and let the ASP.NET runtime worry about creating all the HTML dynamically at execution time.
Take a look at this graphic which depicts the steps that occur whenever a user requests a dynamic web file in their web browser and the request goes to the ASP.NET runtime. Click to enlarge.
Step 1 - The user requests a web page. For example: http://bogusinternetserver.com/mywebpage.aspx
Step 2 - The web page request goes to the web server program.
Step 3 - The web server notices that the file being requested has an extension of .aspx so it transfers execution control to the ASP.NET runtime.
Step 4 - The ASP.NET runtime dynamically executes the code associated with the page mywebpage.aspx. At this point in time, a dynamic web application is running. During the execution of the dynamic web application, many things can occur. The application can communicate with a database. It can process a credit card order. It can perform a search. It can do whatever dynamic operation the programmer who coded the web page had designed the application to do. After the execution is finished, the ASP.NET runtime produces the output which is an HTML formatted document.
Step 5 - The HTML document is delivered to the browser and the user sees the results as a formatted web page with hyperlinks, text, images and all the other things you typically find when you view a web page on the Internet.
So now that we know what the ASP.NET runtime is, then what exactly is ASP.NET?
ASP.NET is a broad high level term that consists of:
-A software server program (the ASP.NET runtime) that interacts with the web server to execute dynamic web pages.
-Development tools (Visual Web Developer and Visual Studio).
-Programming languages (C# and VB.NET).
-The .NET framework libraries.
All of these items together make up the Microsoft ASP.NET web platform, commonly known as “ASP.NET”.