1. Technology

What is ASP.NET?

The Microsoft way to create web applications

By

ASP.NET is Microsoft's web server technology that powers dynamic websites running Microsoft IIS web servers. Many websites nowadays are dynamic; the html that makes up the web page is not loaded from a file but is generated at run-time instead. This is what happens: This articles presents an overview of ASP.NET. If you are new to programming you might like to read Sequence of Events in loading a web page:
  1. Browser requests a web page.
  2. The web page code is loaded into memory.
  3. The web page code is compiled the first time it is loaded and its machine code is cached.
  4. The machine code is executed. This outputs html which is sent to the browser.
An ASP.NET website is made up of several web forms each of which is made up of two pages. One is html (which is not compiled) and the other is either C# or VB.NET.

Web sites have gone through several generations of technology:

  1. Simple HTML pages.
  2. CGI (Common Gateway Interface). A compiled exe is loaded and run for every page request. Inefficient!
  3. ISAPI DLL. A Dll that processes every request; this was invented by Microsoft.
  4. Interpreted Scripting Languages: eg ASP (the precursor to ASP.NET), JSP (Java Server Pages), PHP (the most popular open source web technology) and many others.
  5. ASP.NET. Compiled C#/VB.NET. (Or any .NET languages that runs on the CLR eg C++/CLI). This is now up to version 3.5.
Though scripting languages are interpreted, recent versions such as PHP are also compiled at run-time so that the traditional speed difference between compiled and interpreted code is much less.

As well as running compiled code, an important aspect of ASP.NET is that it allows you to separate the HTML/XHTML from the C#/VB.NET code. One of the biggest criticisms of other server side technologies is that they were implemented by adding the code within html pages using special tags. It looks horrible and be difficult to maintain. PHP addressed this with a variety of 3rd party templating technologies but ASP.NET now has it built in since version 2.0. Under original ASP you might have had a page Default.asp containing html with embedded VbScript (the interpreted script language).

Under ASP.NET you have these two files per page:
  • Default.aspx
  • Default.cs
It is possible to code inline instead of the two file (known as the code-behind model) but the two file method is the recommended one. It allows teams to have designers work on the HTML/CSS (i.e./ the look and feel of the application) while developers work on the functionality. Traditionally developers are useless at design and designers just can't code.

Master Pages

Microsoft have taken a trick from their PowerPoint application with Master Pages. In PowerPoint you can create a Master Slide that acts as a template for all other slides. The background and common text on the Master Slide is automatically used in other slides.

Likewise the Master Page is used to create the look and feel of an ASP.NET web application. Content place holders are used to allocate places on the Master Page that will be changed on the content pages. Most web pages have a non visible part (called the head) as well as the body which is the visible part. In the head you specify certain Meta fields such as the page description and keywords. These vary from page to page so if you're using a Master Page then this is where you would put one Place Holder. You can have multiple Place Holders on the same page.

When a page is loaded, if a Master Page exists for it then the two are combined with the content from the page filling in the place holders on the Master Page. If you have ever hand coded a website then by comparison this simplifies enormously the task of maintaining a big site.

Events

One of the more problematic aspects of web development is firing events when a web page loads. Usually this is done by just putting in some JavaScript which runs after the page is loaded. With ASP.NET 2.0 and higher there are a number of events that can be processed as the page loads, in this order.
  1. PreInit - Just before the page is initialized
  2. Init - as the page is beining initialized
  3. InitComplete - after the page has been initialized
  4. PreLoad - before the page has loaded into memory
  5. Load - as the page is loaded
  6. LoadComplete - after the page has loaded
  7. PreRender - before the page is rendered in the browser
  8. PreRenderComplete - after the page has been rendered
  9. Unload - as the page is unloaded.
Event handling is a major strength of ASP.NET and makes it more akin to Windows Gui development.

Server and Web-Server Controls

ASP.NET supports two type of controls. Simple HTML server controls and the more complex Web server controls. The HTML controls are intended for converting older ASP websites to ASP.NET. Just add the tag runat="server" to a normal HTML control such as forms, input or buttons.

Web server controls are a bit like controls you drop on forms and provide more complex functionality. For example it's a lot easier to populate a drop-down at run-time using a drop-down control. As well as better versions of the standard HTML controls there are much more sophisticated controls: calendar server, panel server, file upload and even a wizard server control.

Conclusion

Much as programming languages have evolved from machine code up to higher level languages, web development has moved on from simple client html output to more complex server side technology. The ultimate web sites of course are sophisticated Contents Management Systems (CMS) where everything about the site is stored in databases and generated on the fly. But those are expensive and for building normal websites ASP.NET is about the most advanced server-side technology currently in existence.

We will have ASP.NET tutorials here but they are not here yet.

  1. About.com
  2. Technology
  3. C / C++ / C#
  4. Getting Started
  5. What is ASP.NET?

©2014 About.com. All rights reserved.