.NET Framework Drill Down


The .NET Framework consists of four major areas:

  • Application development technologies.

  • Class libraries.

  • Base class libraries.

  • The Common Language Runtime.

These pieces sit on top of each other, with each of the higher layers making use of one or more of the lower layers , as shown in Figure 2-9:

click to expand
Figure 2-9:

We have already discussed the CLR and base class libraries, so in the next sections we'll briefly examine the top two layers “ the application development technologies and the class libraries. These layers are the primary focus for the remainder of this book.

Application Development Technologies

As you saw in Chapter 1, ASP.NET is a very exciting .NET technology for building web applications, providing many new features and a much cleaner programming mode. The features you're going to look at next are:

  • Web services.

  • Windows Forms.

Web Services

In the intelligent fridge example, we discussed the idea of a fridge talking to a supermarket over the Internet to automatically restock it. To achieve this, supermarkets would have to expose over the Internet the APIs for any fridge to call upon to place orders. It would also be necessary to locate such services, providing the fridge owner with the means to pick a supermarket to order from. This concept of locating and consuming programmatic functions over the Internet is called web services .

Important

Web services are programmable business logic components that serve as "black boxes" to provide access to functionality via the Internet using standard protocols such as HTTP.

Web services are based upon an application of XML called the Simple Object Access Protocol (SOAP) . SOAP defines a standardized format for enveloping the XML payloads exchanged between two entities over standard protocols such as HTTP. SOAP is based completely upon open standards. The consumers of a web service are therefore completely shielded from any implementation details about the platform exposing the web service “ they simply send and receive XML over HTTP. This means that any web service on a Windows platform can be consumed by any other platform, such as UNIX.

Note

More technical details on SOAP can be found at http://www.w3.org/TR/SOAP/.

Web services are a core part of the .NET Framework. Using ASP.NET you can easily expose web services from a Web site, and can easily consume web services from other web sites. To make this whole model simple for .NET developers, you have to do little more than write a class to expose a web service, or consume a class to use a web service. This saves you from having to understand protocols such as SOAP in any detail, but you can be sure that anybody can access the functionality you provide.

The following Visual Basic .NET code defines a simple web service with a single function called NameABook :

  <%@ WebService Language="VB" class="MyWebService" %>   Imports System   Imports System.Web.Services   Public Class MyWebService   <WebMethod> _   Public Function NameABook() As String   Return "Professional ASP.NET"   End Function     End Class  

Here is the same web service, this time written in C#:

  <%@ WebService Language="C#" class="MyWebService" %>   using System;   using System.Web.Services;   public class MyWebService   {   [WebMethod]   public string NameABook()   {   return "Professional ASP.NET";   }   }  

To host these web services within an ASP.NET page, all you have to do is copy the code into a standard text file, and save that file in the ASP.NET application directory, giving the file an .asmx extension. When the ASP.NET runtime sees a request for an .asmx file, it knows that the file being requested represents a web service. It will automatically decode the incoming SOAP request, invoke the appropriate function, and send out a SOAP/XML response.

There are more facets to web services, such as security, describing the web services available on a given site, and providing the means to locate web services via a certain discovery service. Web services are discussed in Chapters 19 and 20.

Windows Forms

For developing traditional Windows GUI applications, the .NET Framework provides you with Windows Forms .

Important

Windows Forms is an extensive class library that exposes the functionality of Windows Common Controls using the expressive object-oriented capabilities of the .NET Framework.

If you have ever developed a Form in VB6 using the Forms designer, or created dialogs using VC++ and MFC, you'll be right at home with Windows Forms in .NET because a lot of the classes are similar. Windows Forms uses a designer similar to previous versions of Visual Studio, but the controls expose richer functionality and are object oriented. The net result is that you produce applications that look pretty much as they do today, but with less code; the code is cleaner and easier to understand.

Another important advance with Windows Forms is that you now have a single GUI library and forms designer for all of the supported languages. Whether you program in VB, C++, or one of the newer languages such as C#, you'll be using the same classes, methods , and events, since they all use the same class library: System.Windows.Forms . The benefits this brings to programmers are very important. Since the same class library is being used, all of the languages have the same capabilities. This means you can use the language you're most comfortable with, and don't have to worry about whether the language you choose has the same features as are available, say, in C/C++. This is a problem you might well have encountered in the past.

Class Libraries

The .NET Framework has an extensive set of class libraries. This includes classes for:

  • Data access :High-performance data access classes for connecting to SQL Server, Oracle, or any other database for which an OLEDB or ODBC provider is available. See Chapter 9.

  • XML support :Next generation XML support that goes far beyond the functionality of MSXML. See Chapter 11.

  • Directory services :Support for accessing Active Directory/LDAP using ADSI.

  • Regular expressions :Support beyond that found in Perl 5. See Chapter 15.

  • Queuing support :Provides a clean object-oriented set of classes for working with MSMQ.

These class libraries use the CLR base class libraries for common functionality.

Base Class Libraries

The base class library in the .NET Framework is huge. It covers areas such as:

  • Collections :The System.Collections namespace provides numerous collection classes. See Chapter 15.

  • Thread support :The System.Threading namespace provides support for creating fast, efficient, multi-threaded applications.

  • Code generation :The System.CodeDOM namespace provides classes for generating source files in numerous languages. ASP.NET uses these classes when converting ASP.NET pages into classes, which are subsequently compiled.

  • IO :The System.IO namespace provides extensive support for working with files and all other stream types.

  • Reflection :The System.Reflection namespace provides support for load assemblies, examining the types within assemblies, creating instances of types, and so on.

  • Security :The System.Security namespace provides support for services such as authentication, authorization, permission sets, policies, and cryptography. These base services are used by application development technologies like ASP.NET to build their security infrastructure.

The list of support base classes goes on forever in .NET, but if you ever find yourself lost looking for a specific class, you can use the WinCV tool to locate it. You can run this from the Start Run menu. The file is usually located in the C:\Program Files\Microsoft.NET\SDK\[ version ]\Bin folder.

The WinCV tool allows you to type in a search string, and brings back a list of all the matching types it finds. For example, Figure 2-10 shows the results of typing HttpRequest (the ASP.NET class that is the Request object, also called the Request intrinsic). The left-hand pane shows all of the types matched. The right-hand pane shows the type definition, retrieved using the reflection classes. Using the information shown, you can determine that the HttpRequest class is defined as part of the System.Web namespace, which is contained in the System.Web.dll file.

click to expand
Figure 2-10:

By now you should have a fairly good picture of how the .NET Framework fits together, so let's look at some of the ASP.NET design goals, and see how the .NET Framework was used to build ASP.NET.




Professional ASP. NET 1.1
Professional ASP.NET MVC 1.0 (Wrox Programmer to Programmer)
ISBN: 0470384611
EAN: 2147483647
Year: 2006
Pages: 243

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net