migrating existing asp applications to asp.net an in-depth look at the paradigm shifts and upgrade...

24
Migrating Existing ASP Migrating Existing ASP Applications to ASP.NET 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)

Post on 20-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 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

Migrating Existing ASP Migrating Existing ASP Applications to ASP.NETApplications to ASP.NET

An in-depth look at the paradigm shiftsand upgrade strategies when moving from ASP to ASP.NET architectures.

By Carl ProthmanMicrosoft “Most Valuable Professional” (MVP)“Certified Computer Professional” (CCP)

Page 2: 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

IntroductionsIntroductionsCarl 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: [email protected]

Able Consulting, Inc.– Owner http://www.able-consulting.com

Page 3: 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

AgendaAgenda .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

Page 4: 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

Overview 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 applicationsWeb Forms and XML Web ServicesHTTP Runtime Architecture with IIS

Page 5: 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

ASP.NET– Overall ViewASP.NET– Overall View

Devices

XML WebServices

WinForms(EXE)

WebBrowsers

ASP.NETXML WebServices

ASP.NETWeb Forms

Code Behind Files

Business& DataClasses

StoredProcedures

DataSet

DataReader

Database

IIS SQL Server

Cache

COM+

Internet

DataSet

Page 6: 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

AgendaAgenda

.NET OverviewParadigm Shifts 25 mins Migration Strategies Summary

Page 7: 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

ASP.NET Paradigm ShiftsASP.NET Paradigm ShiftsWhat 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!

Page 8: 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

ASP.NET - Paradigm ShiftASP.NET - Paradigm Shift0) Remote Application Communication0) 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

Page 9: 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

ASP.NET - Paradigm ShiftASP.NET - Paradigm Shift1) Server-Side Web Controls 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)

Page 10: 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

ASP.NET - Paradigm ShiftASP.NET - Paradigm Shift2) Automatic HTML Code Generation2) 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

Page 11: 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

Paradigm ShiftParadigm Shift3) Automatic Web Control State3) 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!

Page 12: 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

Paradigm ShiftParadigm Shift4) HTML Separate from Code4) 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

Page 13: 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

Paradigm ShiftParadigm Shift5) 5) Compiled ASP.NET Code 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

Page 14: 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

Paradigm ShiftParadigm Shift6) Registering Client-Side Script6) 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

Page 15: 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

Paradigm ShiftParadigm Shift7) User Controls Instead of Includes7) 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

Page 16: 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

Paradigm ShiftParadigm Shift8) 8) XML Configuration FilesXML Configuration FilesIn ASP, you used System Registry (or IIS

Metadata db) to store Application settingsIn 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 usingSystem.Resources.ConfigurationSettings.AppSettings[“myKeyName"]

Page 17: 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

Paradigm ShiftParadigm Shift9) ASP.NET Worker Process9) 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

Page 18: 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

Paradigm ShiftParadigm Shift10) Windows Impersonation10) 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

<authentication mode="Windows" /> <identity impersonate="true" />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)

Page 19: 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

AgendaAgenda

.NET Overview Paradigm ShiftsMigration Strategies 20 mins Summary

Page 20: 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

Migration Strategies Side-by-SideMigration 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.NET1. Rename the ASP file to use the “.ASPX” file extension2. 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– …

Page 21: 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

Migration StrategiesMigration Strategies- Tier by Tier- Tier by Tier First Convert the UI Tier

– Create new WebForms / User Controls– Call existing COM Components

Next Convert the Business Tier– Create Class Modules for each Business class– If Internet clients need to reuse these new classes,

create XML Web Services wrappers Finally Convert Any Desktop Database

– Upgrade your old Access MDB to MSDE or SQL Server

Page 22: 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

AgendaAgenda

.NET Overview Paradigm Shifts Migration StrategiesSummary 5 mins

Page 23: 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

SummarySummary

Reviewed ASP.NET Paradigm Shifts– Top 10 (make that 11)– But there are a lot more…

Reviewed Migration Strategies– Side by Side Conversion– Tier by Tier Conversion

Better understanding of ASP to ASP.NET Migration Issues

Page 24: 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

Questions?Questions?

Q & AMore Information

– ASP.NET Web Site http://www.asp.net– GotDotNet Web Site http://www.gotdotnet.com

These slides / sample code are at:– http://www.able-consulting.com/