Newest Viewed Downloaded

Migrating Existing ASP Applications to ASP.NET An in-depth look at the paradigm shifts and upgrade strategies when moving from ASP to ASP.NET architectures. By Carl Prothman Microsoft “Most Valuable Professional” (MVP) “Certified Computer Professional” (CCP)

Migrating Existing ASP Applications to ASP.NET An in-depth look at the paradigm shifts and upgrade strategies when moving from ASP to ASP.NET architectures. By Carl Prothman Microsoft “Most Valuable Professional” (MVP) “Certified Computer Professional” (CCP)

Hello my name is Carl Prothman In this session, I will be talking about “migrating existing asp applications to asp.net applications. next

Introductions

Carl Prothman Microsoft “Most Valuable Professional” (MVP) Visual Basic MVP 1998/2002 ASP.NET MVP 2002/2003 Certified Computer Professional (CCP) Microsoft Certified Professional (MCP) Over 22 years of experience in Software Industry Bachelor of Science in Aeronautics and Astronautics (BSAA) from University of Washington Email: carlpr@spamcop.net Able Consulting, Inc. Owner http://www.able-consulting.com First a little about my self… I’m one Microsoft’s most valuable professionals (MVP). In fact I just got award the MVP status for 2002/2003 I’m also a Certified Computer Professional, and a Microsoft Certified Professional I have over 22 years of experience in the software industry Plus I have a degree in Aeronautics and Astronautics from the University of Washington I’m the owner of Able Consulting. You can reach me at the email listed or though my web site. next

Agenda

.NET Overview 1 min What is it? Paradigm Shifts 35 mins Top 10 (make that 11) Migration Strategies 15 mins Side-by-Side Conversion Tier-by-Tier Summary 9 mins Q&A Total: 60 mins So the adenda is as follows I’m going to show you my top 10 (make that 11) paradigm shifts These are the things you must think and do differently when switching from ASP to ASP.NET Then I’m going to show you some strategies on how to migrate from ASP to ASP.NET I will actually convert an ASP file to an ASPX file At the end, if we have time, I’ll try to answer a few questions. next

Overview

What is Microsoft’s .NET? Set of Microsoft software technologies connecting your world of information, people, systems, and devices Enables an unprecedented level of software integration through the use of XML Web services: Small, discrete, building-block applications Connected to each other via the Internet What is ASP.NET? The development platform for building server-based Web applications Web Forms and XML Web Services HTTP Runtime Architecture with IIS So what is .NET? Here is the official Microsoft marketing definition… Note that it focus on XML Web Services And what is ASP.NET? Again here is the official Microsoft marketing definition… Scott Guthrie will be speaking more on the HTTP Runtime Architecture on the Dec 4 meeting My point here is that when I think of ASP.NET, not only do I think of XML Web Services, but I also think of Web Forms! But there is my view of all of it. [Next slide]

ASP.NET– Overall View

This diagram shows the different way you can connect the different pieces of ASP.NET If the client side user is communicating over the Internet, then go through an XML Web Service. If the client side user is communicating on an Intranet / LAN, then go though a business class or the database directly. When using web forms, the fastest way to get data from a SQL Server database is to use ADO.NET’s SQL Client .NET Data Provider to call a Stored Procedure in SQL Server, and return a DataReader, which you bind to Web Controls on the Web Form. If the query is expensive to make (lots of joins / calculations), then return a DataSet and put the DataSet into ASP.NET’s Cache on the first request. Then when requests come in for the same data, use the DataSet from the cache. - The recommendation is to use XML Web services to communicate between internet apps. - Xml web services should not be positioned as a replacement for binary protocols between servers on the same network/environment. Next

Agenda

.NET Overview Paradigm Shifts 25 mins Migration Strategies Summary Next, I’m going to talk about my top 10 paradigm shift that have occurred from ASP to ASP.NET But first, what is a paradigm shift? Next

ASP.NET Paradigm Shifts

What is a Paradigm Shift? A set of concepts, values, practices and assumptions that constitutes a way of viewing reality for the community that shares them. When one paradigm looses influence and another paradigm takes over, then there is a paradigm shift! Knowing in advance how a Paradigm Shift might occur gives you an advantage over others! A paradigm shift is… A set of concepts, values, practices and assumptions that constitutes a way of viewing reality for the community that shares them. When one paradigm looses influence and another paradigm takes over, then there is a paradigm shift! Knowing in advance how a Paradigm Shift might occur gives you an advantage over others! That is where you benefit. I’m going to show you the details of each paradigm shift (at least my top 10 ones). Next

ASP.NET - Paradigm Shift 0) Remote Application Communication

In ASP, you used the RDS DataSpace to communicate to a remote COM+ Component over DCOM or HTTP(S) RDS is a major security hole! RDS DataFactory MS99-025 RDS Data Stub MS02-065 In ASP.NET, you now use an XML Web Services to communication to remote applications Standard protocol (SOAP) for distributed environments Over HTTP with XML SOAP Envelop / Payload The first paradigm shift is called “Remote Application Communication” Note, This paradigm shift starts a zero, since .NET arrays are zero based – you better get use to it… ha ha… Demo: Create a simple Hello World XML Web Service => Run and Test Create a WebForm with a Label and Button Add a reference to the XML Web Service (creates a proxy class) In the Button click event, call the XML Web Services and display the returned text into the Label = Run and Test Paradigm Shift: You now have the ability to communicate with remote applications (on different platforms) using the SOAP standard. XML Web Services implements the SOAP standards for you automatically. - The recommendation is to use XML Web services to communicate between internet apps. - Xml web services should not be positioned as a replacement for binary protocols between servers on the same network/environment.

ASP.NET - Paradigm Shift 1) Server-Side Web Controls

In ASP, you used Response.Write or <%= % to send HTML / script to the Web browser In ASP.NET, you can now program against server-side Web Controls which generate the HTML HTML Server Controls HTML Tag with and ID= and RunAt=Server attributes Web Server Controls ASP.NET control with ID= and RunAt=Server attributes Form Validation Controls Client-side and Server-side Validation User Control Page (.ASCX) Replaces the HTML Include command Custom Control Assembly (.DLL) Demo Create a new Web Form Add a Label, TextBox and a Button Double click Button Make it so value in TextBox gets shown in Label Set a break point in the Button on-click event => Notice that you are programming against server-side Web Control 6) Run => Notice that the Form Load event fires on each GET and POST 7) Enter “Hello World” in textbox 8) Click Submit button => By default AutoPostback is false for all controls, except for Button Web Control => Notice the event is raised on the server when button is clicked on client! Paradigm Shift: You are programming against **server-side** Web Controls which display HTML on the client! All client-side events for the Web Controls are raised on the server during postback!

ASP.NET - Paradigm Shift 2) Automatic HTML Code Generation

In ASP, you created custom pages for each browser type Use browscap.ini file with the BrowserType object In ASP.NET, you use server-side Web Controls and Web Forms to generate the HTML ASP.NET figure out the browser type Automatically renders the correct, browser-compliant HTML for features such as Styles, Layout, and so on. In Visual Studio .NET, set TargetSchema Property on the Page Internet Explorer 3.02 / Navigator 3.0 Internet Explorer 5.0 Navigator 4.0 How many of you remember coding to Netscape and IE browsers? Demo Show web form with label, textbox, and button web controls using **GridLayout** (which uses absolute positioning) Set TargetSchema to Internet Explorer 5.0 => View source reveals absolute position HTML code Set TargetSchema to Internet Explorer 3.02 / Navigator 3.0 => View source reveals table HTML code Paradigm Shift: You let the Web Form / Web Controls generate the **browser specific** HTML, rather than coding it yourself! You no longer need to use the old “table placement” trick!

Paradigm Shift 3) Automatic Web Control State

In ASP, you had to fill the control with user entered values on POST back Show the web page again with an error message In ASP.NET, the controls automatically retain the user entered values on POST back ViewState is used to store Control State User selection, Control Info… Control values are automatically filled in for you during post back. Can store values in ViewState between round trips Must only use one FORM on page Must post to the same page for ViewState to work! Demo Show Web Form with Listbox Select a value Click Submit button => On post back the control retains its selected value View the Source => Show ViewState hidden input control Paradigm Shift: Controls are automatically recreated with user selection during post back. You don't have to worry about resetting controls to last state

Paradigm Shift 4) HTML Separate from Code

In ASP, you could mix HTML with client-side and server-side script Hard to read and maintain Some used “.vbs” or “.js” files to separate out the script In ASP.NET, you can either Put the code in-line with SCRIPT tags Or put code in a “code-behind” page Visual Studio .NET creates code-behind pages by default ASP.NET Web Matrix creates in-line SCRIPT tags by default In VS.NET click “Show All Files” Shows HTML file and Code File In Web Matrix, open web form show In-Line Code Paradigm Shift: Now use code behind pages rather than mixed HTML/Script or .vbs files Separate out the UI Controls from the code!

Paradigm Shift 5) Compiled ASP.NET Code

In ASP, you used server-side VBScript (or JavaScript) which was interpreted, hence slower! So most folks just pulled the server-side script out and put it into a VB 6.0 / C++ COM+ Components (N-Tier) Presentation Tier Classes Business Tier Classes Data Tier Classes In ASP.NET, everything is compiled, which is faster! In-line SCRIPT tags with RunAt=Server Code Behind page (must compile) Debug –vs- Release mode Demo Create new web form page, with TextBox and Button Double click on the button to create a code behind page Put some code in Browse to the new web page => “Could not load type 'ASPNET.WebForm2‘” => Need to compile “code behind page” since Inherits="ASPNET.WebForm2" Compile the project (Ctrl Shift B) Refresh web page => Now page is found Paradigm Shift: Everything is compiled, not interpreted, which means greater performance! You must compile code-behind pages before you can browse to the page!

Paradigm Shift 6) Registering Client-Side Script

In ASP, you could directly add client-side event handlers to HTML controls In ASP.NET, you add client-side event handlers to Web Controls via Attribute.Add Button1.Attributes.Add(“onclick”, “alert(‘Hello’)”) You can also register a client script block RegisterClientScriptBlock Client-side JavaScript / JScript VBScript Demo Show WebControl Add code for client-side onclick event Add script block Run Paradigm Shift: Must add / register client-side script with Web Controls

Paradigm Shift 7) User Controls Instead of Includes

In ASP, you used includes files to include common script code In ASP.NET, you now use User Controls (ASCX) for common code Headers, Footers, etc.. Public Properties and Methods Inheritance from BaseControl Reuse common Properties, Methods, and settings Demo Show User Control Drag and drop onto a page Write code to set user control Run Paradigm Shift: Use User Control Pages instead of server-side Includes User Controls are object oriented => Inherit from base user control and reuse common properties, methods, and events.

Paradigm Shift 8) XML Configuration Files

In ASP, you used System Registry (or IIS Metadata db) to store Application settings In ASP.NET, you use XML files to store Application settings Machine.config (for all projects on the machine) C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config Web.config (for each project) Read in configuration settings using System.Resources.ConfigurationSettings.AppSettings[“myKeyName"] Demo Show the web.config file Show the machine.config file We can read in the configuration setting from these config file using System.Resources.ConfigurationSettings.AppSettings[“myKeyName"] Paradigm Shift: Use XML files to store configuration rather than System Registry or IIS MetaData

Paradigm Shift 9) ASP.NET Worker Process

In ASP, IIS used the ASP.DLL to handle each web request In ASP.NET, IIS calls an ASPNET worker process (aspnet_wp.exe) Identity of ASP.NET Worker process controlled by machine.config, processModel element, userName attribute C:\WINNT\Microsoft.NET\Framework\v1.0.3705\CONFIG\machine.config "MACHINE": runs as low privilege user account named "ASPNET". "SYSTEM": runs as localsystem (high privilege admin) account. Running IISRESET stops the Worker process Demo Browse to WebForm2.aspx Show Windows Task Manager => aspnet_wp.exe is running Run IISRESET => aspnet_wp.exe stops running Refresh WebForm2.aspx => aspnet_wp.exe is running again Paradigm Shift: IIS now calls an ASP.NET Work Process to handle the request rather than handling the request itself! ASP.NET Work Process runs as the “low privilege” ASPNET User Account by default! This mean stronger security by default. Hence you must enabled the correct permissions!

Paradigm Shift 10) Windows Impersonation

In ASP, impersonation was enabled by default Using Anon Access, ASP would impersonate IUSR_XXXX Using NTLM / Basic, ASP would impersonate calling User In ASP.NET, impersonation is disabled by default You must explicitly enable impersonation in web.config or machine .config file System.Security.Principal.WindowsIdentity.GetCurrent().Name CARLP7\ASPNET (ASP.NET User account) CARLP7\IUSR_CARLP7 (IIS Anon User account) CARLP7\Administrator (User account that I’m logged as) Demo Open up the web.config file - Show that we are using Windows authentication - Show the Identity tag with impersonate attribute = false (default) Open up IIS MMC and show the security for the IIS Application - Chance to anon and refresh the page - Identity impersonate=“false“ and IIS Anonymous Access => WindowsIdentity.GetCurrent().Name = CARLP7\ASPNET - Identity impersonate=“false“ and IIS NTLM => WindowsIdentity.GetCurrent().Name = CARLP7\ASPNET - Identity impersonate=“true“ and IIS Anonymous Access => WindowsIdentity.GetCurrent().Name = CARLP7\IUSR_CARLP7 - Identity impersonate=“true“ and IIS NTLM => WindowsIdentity.GetCurrent().Name = CARLP7\Administrator Paradigm Shift: Windows Impersonation is OFF by default in ASP.NET Must use for ASP.NET worker process to impersonate client.

Agenda

.NET Overview Paradigm Shifts Migration Strategies 20 mins Summary So that concludes my top 10 Paradigm Shifts. Now I want to focus on strategies to migrate ASP to ASP.NET next

Migration Strategies Side-by-Side

ASP and ASP.NET Side-by-Side Both ASP and ASP.NET files can run side-by-side in same IIS Web Application However, you cannot share Session variables between them directly Steps to “convert” ASP to ASP.NET Rename the ASP file to use the “.ASPX” file extension Browse to the page and update server-side code as needed Option Explicit is the default. Remove Option Explicit line. Method calls with parameters require “(“ and “)”. Don’t need Set or Let anymore. Remove them. For ADO/COM objects, use “aspcompat=true” in the Page directive “&” must have spaces around it. No more s = str1&str2 No more Default Properties. Must state explicitly: oRs(0).Value No more VBScript Variants => Objects / .NET Framework Class Library ByValue is now the default. Was ByRef in VB 6.0. VB.NET is now 0 based. Was 1 based (in some cases) in VB 6.0 Integer data type is now 32 bits. Was 16 bit in VB 6.0 … The first migration strategy is called Side-by-Side. This is where both your ASP and ASP.NET pages live in the same IIS application. Both ASP and ASP.NET applications use different file extension. So they both can be in the same directory. However, even if they are in the same IIS application, you cannot share Session or Application variables between them. The steps to convert an ASP file to an ASPX fie are as follows: 1) First rename the ASP file extension to an ASPX file extension 2) Next update the code as necessary For example: Open up sidebyside.asp Step through code and comment about what it does Make a copy of the file and call it sidebyside.aspx Browse to sidebyside.aspx FIX #1 – Noticed it moved the VBSCRIPT language tag automatically to the page directive. FIX #2 – Add Explicit="True" to Page, and remove Option Explicit line SET and LET??? FIX #3 – Add ( and ) to Response.Write line Fix #4 – Add aspcompat=true to the page directive. => The ASP page now has been converted to ASPX page Note a VB.NET page in a C# Project => But the page is still using classic ADO via COM Interup (slow). Need to convet to ADO.NET with SqlClient .NET Data Provider => Also the page is still using HTML controls. Need to convert over to Web Controls

Showing 1 - 20 of 24 items Details

Name: 
asp_aspnet
Author: 
Carl Prothman
Company: 
Able Consulting, Inc.
Description: 
Migrating Existing ASP Applications to ASP.NET An in-depth look at the paradigm shifts and upgrade strategies when moving from ASP to ASP.NET architectures. By Carl Prothman Microsoft “Most Valuable Professional” (MVP) “Certified Computer Professional” (CCP)
Tags: 
asp | net | side | paradigm | web | control | shift | server
Created: 
9/28/2002 3:31:19 AM
Slides: 
24
Views: 
12
Downloads: 
0
Rating: 
0


> Comment



Share this presentation
|

Comments

Share this presentation:

|
Sitemap