The .NET Framework


Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 1.  Getting Started with ASP.NET

Where does the .NET in ASP.NET come from? It stands for the .NET Framework, a set of objects and blueprints from Microsoft for building applications. The .NET Framework provides the underlying functionality of ASP.NET.

All applications developed under the .NET Framework, including ASP.NET applications, have certain key features that ensure compatibility, security, and stability. Let's examine these features individually.

Common Language Runtime

The Common Language Runtime (CLR) is an environment that manages the execution of code. In other words, it runs and maintains any code that you write.

Traditionally, when you create an application, you write some code in a programming language (such as Visual Basic), compile it into a format that the computer can understand (1's and 0's), and then execute it. Note that different types of computers speak different languages (for instance, PCs and Macintoshes). This means that every time you want to use an application on a different type of computer, you have to recompile it to the new computer's language. In the .NET Framework, things work a little differently.


With the .NET Framework and CLR, you still write code and compile it. However, instead of compiling it into something the computer understands, you compile it into a language called the Microsoft Intermediate Language (MSIL). This language is a shorthand way of representing all the code you've written. ASP.NET pages are compiled into MSIL as well. When you compile to MSIL, your application produces something called metadata. This is descriptive information about your application. It tells what the application can do, where it belongs, and so on.


Along with MSIL and metadata, a new class of programming language compilers has been created for C#, COBOL, Perl, and so on. These compilers are similar to existing ones, but now can output MSIL as well as compiled code.

Then, when you want to run your program, the Common Language Runtime takes over and compiles the code once more into the computer's native language. This way MSIL can go on any type of computer. The CLR can speak many different computer languages and does all the compiling for you. Once you compile your application, you can bring it to any other computer! Figure 1.3 illustrates the difference between the traditional process and the .NET Framework.

Figure 1.3. The traditional application framework versus the .NET Framework.



If you're familiar with the Java platform, you may see the similarities here. Java code is also translated and executed by a run-time environment called the Java Virtual Machine (JVM). This allows a developer to write code, compile once, and have the JVM handle any cross-platform issues.

The CLR uses the metadata to find out how to run the application, which makes it very easy to install programs. The traditional method required information about the application to be stored in a registry or a central depository for application information. Unfortunately, the registry would be invalidated whenever an aspect of your application changed (its directory was moved, a new component was installed, and so on), and the application wouldn't run properly. With metadata, there's no need for the registry. All necessary information is stored with the application files, so any changes you make are put into effect automatically. Imagine installing a new application just by copying some files!


Code that works with the CLR is called managed code. This is because the CLR manages its execution and provides benefits (such as resource management) without the developer having to build it manually. Code that's run outside of the CLR is known as unmanaged code.

That's not all the CLR does, however. It provides services such as error handling, security features, versioning and deployment support, as well as cross-language integration. That means you can choose any language you want to write your .NET applications, including ASP.NET applications!

.NET Framework Classes


The .NET Framework comes with blueprints that describe programming objects. Everything in the .NET Framework is treated as an object ASP.NET pages, message boxes, and so on. These objects are placed into logical groups called namespaces. For example, all objects that deal with databases are in the System.Data namespace, all XML objects are in the System.Xml namespace, and so on. Grouping objects this way is a very useful way to build libraries of objects. You'll be using namespaces as you build your ASP.NET applications.


Again, you can see similarities to Java. The .NET namespaces are similar to Java packages.


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    Similar book on Amazon © 2008-2017.
    If you may any questions please contact us: