Sunteți pe pagina 1din 4

A comparison between ASP.NET 1.x and ASP.NET 2.

0
By Benoy Baskaran | 17 Mar 2006
.NET1.1.NET2.0VS.NET2003VS2005C#VBASP.NETWindowsDevIntermediate

This article explores a comparison chart between ASP.NET 1.x and ASP.NET 2.0. See Also
More like this More by this author

5
Article Browse Code Stats Revisions

3.33 (30 votes)

Sponsored Links

Introduction
This article explores a comparison chart between ASP.NET 1.x and ASP.NET 2.0. The following table explains some of the differences between ASP.NET 1.X and ASP.NET 2.0. ASP.NET 2003 ASP.NET 2005 During the compilation of In Visual Studio 2005, you no longer need to compile all the applications for .NET 1.x, files into an assembly. The ASP.NET dynamic compilation engine Visual Studio 2003 would allows to automatically compile applications, that automaticallycompile only includes .aspx, .cs, .vb files. That means, simply create an certain file typessuch as application and publish it. ASP.NET pages, Web services, user controls, A shared class consists of reusable source components in the HTTP handlers, Resource code folder. files, andGlobal.asax class files. The rest of the files The new code-separation model extends the Compile-onneeded to be explicitly Demand feature to the classes bound to a Web page, but it does compiled before finally not stop there; helper classes can also take advantage of it. You publishing your code to the can keep your helper classes and business objects in web server. the App_Code folder. ASP.NET monitors the folder and compiles any new class file that is added or edited. The resulting assembly is automatically referenced in the application and shared between all pages participating in the site. You should put only components into the App_Code folder. Do not put pages, Web user controls, or other non-code files containing non-code elements, into theApp_Code subdirectory. All the files in the App_Code folder are dynamically compiled to a single assembly, named code.dll. The assembly has an

For modifying an application, you need to open the entire project, make changes, and need to recompile again to publish the code to the web server. The code-behind model requires an IIS virtual directory. The code-behind model lacks support for FTP, local file systems, and direct IIS access. It requires IIS on the development computer. Unable to open individual pages outside the project.

application scope and is created in the Temporary ASP.NET Files folder, well outside the Web application space. You just need to open the individual file which you want to make the changes, and publish the code to the web server without having to recompile.

The code-behind model can directly access the local installation of IIS. The code-behind model has multiple ways to open Web sites.

It already has a built-in Web server.

Need not open the entire project; you can open individual pages outside the project, it is achieved through the compile-ondemand feature. It requires explicit addition It eliminates the need to explicitly add files to the project. of files to the project. The compilation models of The new class-derivation model enables the page to define ASP.NET 1.x and ASP.NET controls without the need to have protected members created in 2.0 are built on completely the inherited separation file, or to have explicit event definition. different bases. Pages that use code separation take advantage of a feature known as Partial Classes. When the page runs, ASP.NET 2.0 dynamically creates and instantiates a class representing the page, and the compiler uses the CodeFile attribute in the@Page directive to find the file containing the code. The Inherits attribute defines the name of the class that will be created, and by default, use the page name as the basis for creating the class name. The @Page directive in ASP.NET 2.0 has several new attributes. These attributes allow developers to control new framework features such as personalization and theming. The Page class in ASP.NET 2.0 also has new properties, methods, and events. Properties The properties of the Page object fall into two distinct groups: intrinsic objectsand page-specific properties. Intrinsic objects include references to environmental standalone objects such as Cache, User, and Trace. They also include references to the classic intrinsic objects that form the HTTP context, such as Session, Application, and Request. Pagespecific properties are all the properties that affect or describe

the state of the page, for example,IsPostBack, EnableViewState, and SmartNavigation. The new properties of the Page class can also be categorized into either of the preceding groups. The three important new properties are:

ClientScript - Instance of the ClientScriptManager class that represents a


separate object, and which groups all the methods working with the client-side scripts. Header.IPageHeader - The interface that represents the contents of the page's <head> block if this is marked as runat=server. Master - Gets the master page that determines the overall look of the page.

Methods The Page class features several new methods, most of which are simply inherited from the base Control class. Some of the important methods are:

GetValidators - Returns the collection of all validator


controls that belong to the specified group. SetFocus - Sets the input focus to a particular control contained in the page. RegisterRequiresControlState - Registers the specified control as one that requires control state management.

In the ASP.NET runtime, ASP.NET 2.0 adds quite a few new events to allow you to follow the life cycle of a page is the request-processing more closely and precisely. These new events are discussed in the following table. marked by a series of events. In ASP.NET 1.x, based on user interaction, New Events in ASP.NET 2.0 a page request is sent to the Web server. The event Events Description that is initiated by the page PreInit This occurs before the page begins request is Init. After initialization. This is the first event in theInit event, the life of an ASP.NET 2.0 page. the Load event is raised. InitComplete This occurs when the page initialization is completed. Following the Load event, PreLoad This occurs immediately after the PreRender event is initialization and before the page raised. Finally, begins loading the state information. the Unload event is raised LoadComplete This occurs at the end of the load

and an output page is returned to the client.

PreRenderComplete

stage of the page's life cycle. This occurs when the pre-rendering phase is complete and all child controls have been created. After this event, the personalization data and the view state are saved and the page HTML is rendered.

Developers can dynamically modify the page output and the state of constituent controls by writing these events into the code. For details of code-behind and compilation in ASP.NET, visit MSDN.

Conclusion
This article just focused on some of the common differences between ASP.NET 1.X and ASP.NET 2.0. Some of the concepts, such as partial classes, have greatly simplified things for developers who choose to follow the code-behind model for ASP.NET development without the use of an IDE like Visual Studio .NET. The other features, such as deployment pre-compilation, clearly translate to better performance and protection of intellectual property. On the whole, with the introduction of ASP.NET 2.0, Microsoft has provided developers with a wealth of features with plenty of flexibility.

S-ar putea să vă placă și