Docstoc

asp_aspnet

Document Sample
asp_aspnet Powered By Docstoc
					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)
    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
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
    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
ASP.NET– Overall View
               Internet

    XML Web               ASP.NET
    Services              XML Web                 Data
                          Services                       Se t

    WinForms
                                                  Business
     (EXE)                                                              Stored
                                                   & Data
                                                                      Procedures
                                                  Classes


                                                           er
    Devices                                           Read        t
                                                 Data          Se
                          ASP.NET
                                                            ta
                          Web Forms                      Da
                                              Cache
      Web                                                             Database
    Browsers
                          Code Behind Files



                                     IIS                     COM+            SQL Server
Agenda
   .NET Overview
   Paradigm Shifts        25 mins
   Migration Strategies
   Summary
    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!
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
    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)
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
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!
    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
    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
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
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
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"]
    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
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
<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)
Agenda
   .NET Overview
   Paradigm Shifts
   Migration Strategies   20 mins
   Summary
    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
        1.   Rename the ASP file to use the “.ASPX” file extension
        2.   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
             –   …
Migration Strategies
- 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
Agenda
   .NET Overview
   Paradigm Shifts
   Migration Strategies
   Summary                5 mins
Summary
   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
Questions?
 Q&A
 More 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/

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:4
posted:10/19/2012
language:English
pages:24