Tuesday, April 5, 2011

ASP to ASP.NET Migration

Migrating your web based application from ASP to ASP.NET can open the door of a whole new world of possibilities. ASP.NET is a technology used to create dynamic web application. Migration to ASP.NET can be as simple as running your code through a wizard or just changing the file extension from .asp to .aspx or may be a complete rewrite and rearchitecturing of the application.

It’s not only about upgrading to latest framework and being in sync with world but you also need this to respect frequently changing business demands or technology challenges either to improve operational efficiency or to manage risk. There are lots of advantages of porting your application to ASP.NET over Classic ASP.

ASP to ASP.net Application Migration: Key Features

• It allows code compilation instead of code interpretation, and provides CLR for built in garbage collection to avoid memory leaks.

• Compiled execution - Makes the ASP.NET applications much faster than ASP and the output caching feature eliminate the need to query the database each time the request is made.

• Code behind feature in ASP.NET applications separates the design page with the code page.

• Better Language Support - The .NET platforms supports around 25 .NET compatible languages as compared to ASP, which can support only two scripting languages -- VBScript and JavaScript. Support of more than 4500 .Net framework classes.

• Event-Driven Programming - In-built server controls and event handling helps developers to easily create applications.

• Improved Scalability

• Improved Performance - ASP.NET applications can handle two to three times the request per second as compared to ASP applications

• Easier Configuration and Deployment

• Easier Code Maintenance – Separate layered structure makes code maintenance much easier as compared to ASP, where a single file is used to write HTML, VB script, Java script, and ASP code.

• With an ASP application entire web server may go down if one application crashes but ASP.NET processes run in a different server space and in separate application domain. This saves entire web server to crash just because of one application.


As I said earlier, migrating ASP to .NET framework may look like just changing the file extensions from .ASP to .ASPX, but in reality there are various levels of porting that may be applied to the system. In one scenario, one application may require the implementation of some very basic porting mechanisms and syntactical changes, but another application may demand to have some rich features of ASP.NET and VB.NET such as ASP .NET web controls, Microsoft ADO .NET, the Microsoft .NET framework classes etc. then you may need to develop the new system.

Changes in code

Following are the major areas one will have to take care of, while migrating from ASP to ASP.NET

Core API Changes: These changes refer to the changes made to the API method calls while migration.

Structural Changes: These changes refer to the changes that affect the layout and coding style of an application. For example ASP.NET pages only support one language on a single page where as ASP allowed multiple languages to be used on a single page. ASP.NET page functions must be declared in script runat=server blocks where as in ASP, page functions are declared within <% %> blocks.

Visual Basic Language Changes: VB.NET is a complete programming language as compared to VB Script that was used in ASP.

COM-Related Changes: VB.NET code migration does not force you to incorporate any COM-related changes in your code. Most of these changes are back stage changes and are done automatically. Some changes include the change in threading model, early binding and late binding changes and changes in OnStartPage & OnEndPage methods in the code.

Application Configuration Changes: ASP.NET requires you to store all your configuration settings in Web.config file, which is available in the main application directory.

State Management Issues: ASP.NET does not require you to change your Session or Application objects. On the other hand it provides State Management Options for Inproc, StateServer, SqlServer for improved control on your applications.

Security-Related Changes: ASP.NET supports Windows, Passport, and Forms-based authentication, including cookie management and automatic redirecting of unauthorized logins. Out of these authentication methods, Passport based authentication in a new feature added to ASP.NET. Unlike ASP, ASP.NET does not do per-request impersonation. It does not allow your code to run on behalf of authenticated user.

Data Access: ASP.NET uses ADO .NET, which offers an enormous range of features as compared to ADO to improve your data access methods. Though you need not make any code changes for migration but you can make use of all ADO.NET features in your code.

This migration can happen in two ways:

Vertical Migration – This refers to migrating an application one tier at a time. Vertical migration approach would proceed through all the pages of the one (e.g. user interface) tier for each module, followed by the other (e.g. business and data) tiers. Most appropriate when the application's modules are tightly coupled and minimal changes are required to the interfaces between application tiers.

Horizontal Migration – This refers to migration of an application module by module, completing the migration for all three tiers of one module before moving on to the next. A horizontal migration is most appropriate when application modules are loosely coupled and when interfacing between different application tiers is a tedious task.

Stages of Migration

You may find some tools claiming complete migration, but I recommend not relying completely on tools. Tools can be good for basic migration but advanced migration requirements of the code can only be fulfilled using manual intervention in code.

Following are the main stages of migration life cycle

Analysis: Here you analyze the existing code, and accordingly plan a migration strategy. You should consider the scope of migration, the processes required for migration such as code modification and testing plans. Here you should also identify the .NET specific functionality that can be added to the application or can be replaced with ASP.NET functionality.

Conversion: Here you do the actual code conversion. Start developing and modifying modules for migration. Ensure proper unit testing and peer reviews for the converted code.

Re-factoring: Here you perform code optimization and design improvement. This stage can actually enable you to get long terms gains from the migration and can be helpful in drastically improving the performance of the application.

Testing: Lastly you should conduct functional and non-functional testing for the modules that have been successfully migrated.
Thus, ASP to ASP.NET migration means complete object-oriented programming structure, easy maintenance, reusable code, automatic documentation from reverse engineering, ASP.NET controls, and multiple-language debugger.

Friday, April 1, 2011

Dotnet versions and Application porting

Recently Microsoft released the latest version of their Dotnet framework i.e. DotNet 4.0. Microsoft has always done constant improvement with their Dotnet versions, shown below



I do not see version 4.0 as a package full of new features but I see it more towards making improvements in performance and stressing on doing more parallel processing and multi tasking. Release of version 3.0 was outstanding with new features like WPF, WCF and WF, later with version 3.5 they made version 3.0 features more stable and robust. I do not want to bifurcate my discussion into 3.0, 3.5 or 4.0 but I would like to talk what all we got since 2.0 till 4.0 as a whole.


Recently I migrated one of my application from Dotnet version 2.0 to Dotnet 4.0. Me and my team were so excited for this, as now we will be using all latest features, making it more secure, user friendly, faster and more scalable solution for our client. Visual Studio has made our life much easier and migration is no more a nightmare for developers. VS will take care of most of the things and Dotnet provides high level of backward compatibility.


Out of many enhancements, the very first things I wanted to offer my client was WCF and dump the conventional Web services. I knew WCF is more suitable for my client. They wanted to have following features but were restricted due to technology/platform limitation

• Support for both TCP and HTTP

• Customizable services to their different clients – now possible with different end points

• No need to build application if there is any enhancement – now just provide a new end point

• Same service with different contracts for different types of Clients/Users


I enhanced my application with many more features which Microsoft has offered with Dotnet 3.0 onwards e.g.

• Dynamic lookup

• Named and Optional parameters

• Anonymous Method Support

• Co-variance and Contra-variance

• Dynamic Import

• Omitting Ref Parameters

• Compiling without Primary Interop Assemblies

• Implicit Line Continuation

• In-Process Side-by-Side execution - enables an application to load and activate multiple versions of the common language runtime (CLR) in the same process.

• Garbage collection - .NET 4.0 provides background garbage collection.

• ADO.Net entity framework features


While doing development also me and my team experienced many improvements and new features which makes life easier for both developers as well as client, to name a few

• Performance and Diagnostics - .NET Framework 4.0 provides improvements in startup time, working set sizes, and faster performance for multithreaded applications.

• Profiling – In .NET 4.0, you can attach profilers to a running process at any point, perform the requested profiling tasks, and then detach.

• Exception handling - The .NET Framework 4.0 class library contains the new System.Runtime.ExceptionServices namespace, and adds the ability to handle corrupted state exceptions.

• Reflection - The .NET Framework 4.0 provides the capability to monitor the performance of your application domains.

• Improvement in Microsoft AJAX Library – Script loader, JQuery integration, Client data access etc.

Friday, August 21, 2009

Silverlight 3.0

Silverlight is another new technology from Microsoft Corporation for creating rich browser based applications. It can be easily used to deploy data driven rich applications on browser.

Silverlight can also be defined as a cross platform, cross browser plug-in for developing rich applications on browsers. It exposes a programming framework and features that are a subset of the .Net framework and Windows Presentation Framework (WPF).

The latest version from Microsoft of Silverlight is Silverlight 3.0. Silverlight enables development of the next generation of Microsoft .NET-based media experiences and rich interactive applications (RIAs) for the Web.

Need of Silverlight
ASP.NET AJAX was developed to improve performance in the browser by making post backs and calls between the browser and server asynchronously. ASP.NET AJAX uses new built-in types and controls and JavaScript.

Both ASP.NET and ASP.NET AJAX are heavily dependent upon the ASP.NET page event life cycle, are tightly coupled to the server, and have a tough time competing with advanced, media-rich plug-in solutions such as Adobe Flash. Additionally, it is difficult to create Web applications that offer a consistent experience across all supported browsers and platforms by using ASP.NET and AJAX. In 2006, Microsoft began developing a solution to extend into the browser and offer media experiences more robust than competing plug-in solutions. Silverlight is the result of that search.

Silverlight runs in the browser as a "sandbox" - a secure zone installed into the browser that accommodates Silverlight functionality while completely protecting the host platform from any possibly adverse actions performed by Silverlight

Silverlight Technology

Unlike ASP.NET, the bulk of Silverlight processing occurs on the client machine thus decreasing server resource utilization and improving the Web experience on the client.

When a client initially attempts to run a Silverlight application, if the Silverlight plug-in has not been installed on the client machine, it will be downloaded and installed. Upon subsequent requests to run the application, the application will instantiate on the client machine and make requests for resources from the server only when necessary.

The Silverlight plug-in can be thought of as a scaled-down version of the full .NET Framework. It only contains those classes and functionality that are applicable to a Silverlight Web client and those were streamlined and optimized for use on the Web client machine.

Silverlight was designed using the same design paradigm as ASP.NET. Each page of a Silverlight application includes an associated code behind file that includes the code that handles events fired by the page.

Silverlight resembles WPF in that it uses Extensible Application Markup Language (XAML) to construct the user interface (presentation layer). As Silverlight applications are composed of text-based files that include markup and code, they can be created using any text editor; however, more advanced tools and development environments such as Visual Studio or Expression Blend simplify the task significantly.

Silverlight Architecture

Version 1.0 of Silverlight used JavaScript and supported the industry-leading Windows Media Services enabling delivery of audio and video that includes 2D and vector graphics.
Version 2 includes all features of version 1.0 and:
• Support for the .NET Framework.
• Support for .NET-compliant programming languages such as C#, Visual Basic, Python, and Ruby.
• Support for database operations and language-integrated query (LINQ).

Silverlight Hosting

Microsoft Silverlight functionality is completely encapsulated within the Silverlight plug-in. Silverlight applications simply require a Web server to be equipped as they would be for hosting HTML documents. Silverlight applications can be hosted on any Web server accessible to the target audience. The two most commonly used Web servers are Microsoft Internet Information Server (IIS) and Apache.

Executing a Silverlight application on a Web client machine is a two step process.

First, the application will detect if the Silverlight plug-in is installed on the Web client machine. If the plug-in is not installed, the user will be prompted with an option to download the plug-in. If the user opts to do so, a request will be made of the Web server to download and install the plug-in. The Silverlight plug-in is embodied in a .dll executable file that is loaded into the Web client browser memory once installed. The only interaction required by the Web client when installing the Silverlight plug-in is to grant permission for the plug-in to be installed. Various Web servers, including Microsoft Internet Information Server (IIS), may require slight configuration modifications so that the Silverlight executable file will be downloaded to the Web client when requested.

Second, once the Silverlight plug-in is installed on the Web client machine, the Silverlight application itself must be downloaded. A Silverlight application may consist of many types of files. Slight configuration modifications may be necessary on the Web server, such as MIME types, so that XAML and XAP files are associated with Silverlight and downloaded correctly to the Web client machine when requested.
Once the Silverlight plug-in is installed on a Web client machine and a Silverlight application is downloaded, the Silverlight application is then hosted on the Web client machine.

Silverlight 3.0 additional features

Once the Silverlight plug-in is installed on a Web client machine and a Silverlight application is downloaded, the Silverlight application is then hosted on the Web client machine
• New Controls
o Date Picker, Time Picker etc.
• 3D Projection
• Effects
• Child Window.
• Save Dialog box.
• Image Events.
• XAML Element Binding
• Data Bound Controls
o Data Form, Data Pager, Data Grid.
• Charting Controls.
• Out-Of-Browser Application.
• Merge Dictionaries.
• Local, Network Connection API.
• XAP compression.
• Navigation Framework.
• Analytics.
• Chart Controls.
• RIA Services (In Beta).
• Sketch Flow.

XAP (ZAP) File

.XAP file (pronounced "ZAP") is the compressed output file for the Silverlight application. The .xap file includes AppManifest.xaml, compiled output assembly of the Silverlight project (.dll) and any other resource files referred by the Silverlight application. You can see this in bin/debug folder of your project with projectname.zap.


Silverlight execution process

Our whole project including XAML and other sources are compiled into assemblies (.dll). That is the reason we see that every Silverlight project will always be a user control. This assembly is then combined with the assemblies that our project uses and packaged into a .XAP file. This XAP is then read by the Silverlight runtime in the browser and rendered accordingly. If we look into the output while building our Silverlight project, we can see that it is indeed packaged into XAP file. Traversing to the ClientBin folder in our project location we can see the XAP file generated.


Silverlight Tools


• Tools
o Microsoft Expression
 Expression Blend.
 Expression Encoder.
 Deep Zoom.
o Microsoft Visual Studio 2008
 Silverlight 2 SDK.
Microsoft Silverlight functionality is completely encapsulated within the Silverlight plug-in. Silverlight applications simply require a Web server to be equipped as they would be for hosting HTML documents. Silverlight applications can be hosted in any web server.
Platforms that Support Silverlight

Operating System Browser
• Windows Vista
• Windows XP SP2
• Windows 2000
• Windows Server 2003
• Macintosh OS 10.4.8+ (Intel Based) • Internet Explorer 7+
• Firefox 1.5+
• Google Chrome
• Safari

Microsoft has announced support for Silverlight on mobile devices with a limited initial support for Windows Mobile and the Nokia S60 models.

Early Adopters
Few of the early adopters of Silverlight technology are following and many more
Some example sites are listed below:
• World Series of Poker
• Discovery Channel
• The Emmys
• Home Shopping Network (HSN)
• World Wrestling Entertainment (WWE)
• Fox
• XBOX 360
• Netflix - uses Silverlight to allow subscribers to instantly watch movies on their PCs or Intel-based Macs