Saturday, October 09, 2004




Time and again there have been major changes happening in web development and this time around, it is this version release from Microsoft that is really going to make a difference. From Asp.Net version 1.x to Asp.Net 2.0, many new features have been introduced. The web development is going to become easier and interesting with ASP.NET 2.0. This article being a first insight into this new version, will just lay a hand on the nuts and bolts and will not be dealing with any of the concepts in detail. The following are some of the key features of Asp.Net 2.0:


Ø       Increase developer productivity: Development with ASP.NET 2.0 has reduced the number of lines of code required by 70%. The declarative programming model freed developers from having to write reams of code. More than 45 new server controls in Whidbey that enable powerful declarative support for data access, login security, wizard navigation, image generation, menus, treeviews, portals, and more. This reducing the amount of code required providing better solutions for common Web site scenarios (such as portals and personalized sites).


Ø       Templates: ASP.NET 2.0 has the concept of master page, which provide a template for a consistent look and feel in the web page. A master page is an ASP.NET page that provides a template for other pages, giving shared page-level layout and functionality. The master page defines placeholders for the content, which can be overridden by child pages. This is more or less like a MDI concept in VB.


Ø       Cross Page posting: In ASP.NET 1.x, Web Forms automatically postback to the same page. That is, when a user submits a form, the form data is always submitted back to the same page and the action property cannot be set and which when set might lead to "viewstate corrupted" error.  In ASP.NET 2.0, if the developer wants to post data to a different form, it is now possible. The web form controls have a new property that lets the developer decide where the form data should be sent on a submit action.


Ø       Securing your site: in Asp.Net 2.0, the login functionality includes various set of controls like : i) Login control, providing complete functionality for logging into a site, ii) LoginStatus control, which indicates the login status and can be configured to provide automatic links to login and logout pages, iii) LoginName control to display the current (or anonymous) name, iv) LoginView control, providing templated views depending on the login status, v) PasswordRecovery control, encompassing the "forgot my password" functionality


For example, to add login features to your page all we need to do is add the following code:

<form runat="server">

<asp:Login runat="server" />



Ø       Styles: In ASP.NET 2.0 the concept that deals with the look and feel of a website is that of themes. This is something more or less equivalent to CSS in Asp.Net 1.x, but with a quite different approach.  Some sites provide a selection of stylesheets or alternatively change the stylesheets on the server. This allows not only color schemes to be selected but also complete style choices, such as fonts, style of borders, and so on. In ASP.NET 2.0, this is implemented with 2 concepts named skins and themes. A skin is a set of properties and templates that can be applied to controls. A theme is a set of skins and any other associated files (such as images or stylesheets). Theming, or skinning, has become very popular, allowing users to create a customized look for applications.



Ø       Provide easier and more sophisticated management features. Administration of ASP.NET applications under version 1.x required manual editing of the XML configuration file, which is not a great solution for administrators. Version 2.0 brings a graphical user interface –based administration tool that is integrated with the Internet Information Services (IIS) administration tool.



Now, let's now turn our attention to Code Compilation Model to know how things have changed in ASP.NET 2.0. First, the division of responsibility between base and derived classes goes away. Second, you no longer have to separately compile your user-defined code into an assembly that gets copied into the application's \bin directory. All code, both generated and user-defined is now compiled by the ASP.NET runtime into a single class.

There are two things to notice in an .aspx file. First, there is a new compileWith attribute in the @Page declaration. This tells the ASP.NET runtime the name of the code separation file that contains user-defined code. Second, the ASP.NET 1.x inherits attribute is no longer present. Recall that this attribute told the ASP.NET 1.x runtime what class to derive the ASP.NET page from.

Notice that codebehind file only contains the event handler for control’s event. The reason this code is so much simpler is due to a language feature called partial classes that is new to both C# and VB.NET. This feature lets a class definition span multiple source files, which is how VS.NET and ASP.NET can hide all of the standard initialization code from you. To understand how partial classes work, we need to take a closer look at the code that is generated by the ASP.NET runtime.

First, we need to run the application and force the ASP.NET runtime to dynamically compile your page. When we run our application using VS.NET IDE, actually we will notice two new things. First, there isn't a build step; it immediately start running the Web application. Second thing is that the ASP.NET code no longer runs in IIS during development instead, it runs in a new managed Web server called Visual Web Developer Web Server. This new design means that we don't need to install or configure IIS on a developer's computer. It also means that we can develop ASP.NET code using a restricted user account without having to reconfigure ASP.NET first.

After we run our application for the first time, we need to find where ASP.NET places the generated files. As it turns out, they're in a different location now. Because the Visual Web Developer Web Server runs using our credentials, we will find the files in Local Settings\Temp\Temporary ASP.NET Files\[virtual root]\[x]\[y]. When we look in this directory, actually we should find two .cs files.

There is a new feature in ASP.NET 2.0 that lets you put all related code, i.e. the code that isn't part of an ASP.NET page, in a subdirectory called Code. This can be other source code files, .wsdl files, or .xsd files. ASP.NET will invoke the appropriate command-line tools to compile these source code files at run-time.

have a nice soon with yet another interesting topic....

Comments: Post a Comment

This page is powered by Blogger. Isn't yours?