• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Migration from ASP to ASP.NET
 

Migration from ASP to ASP.NET

on

  • 6,081 views

 

Statistics

Views

Total Views
6,081
Views on SlideShare
6,080
Embed Views
1

Actions

Likes
0
Downloads
88
Comments
0

1 Embed 1

http://www.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Migration from ASP to ASP.NET Migration from ASP to ASP.NET Presentation Transcript

    • Migration from ASP to ASP.NET Anand M. Hegde Developer Support Engineer Microsoft Developer Support Microsoft Corporation
    • Overview
      • Why should you migrate?
      • Introduction to Microsoft® ASP.NET
      • Key changes from ASP to ASP.NET
      • Migrating from ASP to ASP.NET
      • Migrating applications that use COM components
      • Migrating applications that use databases
      • Migration best practices
      • ASP to ASP.NET compatibility FAQ
      • Resources for ASP.NET and migration
    • Why Should You Migrate?
      • Increased scalability and reliability
      • Minimum 2X to 3X performance gain
      • Built-in cross-browser compatibility
      • Rich server-side controls, Microsoft Visual Studio® .NET designer support, and configuration options
      • X-copy deployment of pages and components
      • Better debugger; tracing options
      • Content-code separation
      • Take advantage of new caching features
      • Enhanced state-management features
      • ASP and ASP.NET can run side-by-side if required
      • Many new features
    • Before You Migrate
      • Get a good understanding of ASP.NET
      • Know the changes from ASP to ASP.NET
      • Understand that migration requires code changes
      • Although ASP.NET has excellent backward compatibility, migration may not be as easy as it seems in many cases
    • Introduction to ASP.NET
      • ASP.NET is:
        • A new programming framework for Web applications
        • An overhaul of ASP
        • A part of Microsoft .NET
        • Compiled and event driven programming model
      • It permits you to:
        • Rapidly develop powerful Web applications and services
        • Easily build, deploy, and run Web applications that can target any browser or device
      • It requires:
        • Microsoft Windows® 2000 or later for hosting and development
    • ASP.NET Architecture
    • ASP.NET Request Flow ASPX engine Gen’d page class file Page class ASPX file Request Parse Generate Instantiate, process, and render Response Request Code behind class file Response Instantiate
    • ASP.NET Page Life Cycle
      • ASP.NET pages are event based
      • Event flow in ASPX pages
        • Page_Init: the page and controls are initialized
        • Page_Load: all the controls and page are loaded
        • Change events for controls are processed
        • Click events for controls are processed
        • Page_PreRender: page is about to render
        • Page_Unload: page is unloaded from memory
    • ASP Programming Models
      • Two types of programming models exist
        • ASPX page only: contains HTML, control tags, and code
        • Code behind model: ASPX file contains HTML and control tags, and a “code behind” file contains code
          • A true separation between code and content
      One File Two files. (“code behind” model) Page.aspx Page.aspx Page.aspx.vb <Tags> + Code <Tags> Code
    • ASP.NET Features
      • Life made easy for developers
        • Excellent backward compatibility with classic ASP
        • Visual Studio designer support, rich server controls, and base class library support
        • Write code in the language of your choice
        • Call Microsoft Win32® APIs directly
        • Structured error handling
        • Great debugging and tracing support
    • ASP.NET Features (2)
      • Performance, scalability, and reliability
        • Compiled code means speed
        • Cache APIs to improve performance and scalability
        • Built-in support for WebFarms and WebGardens
        • Nonstop availability and protection against deadlocks, memory leaks, and so on
    • ASP.NET Features (3)
      • Easy deployment
        • X-copy deployment
        • Dynamic updates without interrupting the service
        • No more registry! — u se XML-based configuration files
      • New application models
        • Develop mobile Internet applications with ease
        • Built-in support to use XML WebServices
      • More control with the new security model
      • Flexible session state management
      • Many other new features
    • Core Object Changes
      • Request object changes:
        • Request(item) , Request.QueryString(item) , and Request.Form(item) now return a name value collection
          • In classic ASP, they return an array of strings
      • Use Response.Write with caution
        • It will output results at the top of the page before the <HTML> tag
        • Instead:
          • Use server controls (placeholder)
          • Use <% %> tags if you want the output to appear in the right place
      • Each of the core objects now have many new properties and methods.
      • There are some new objects available
        • For example: cache, user and trace
    • Structural Changes
      • One page – one language
        • No mixing of languages in single page
      • A page can have only one server-side Form tag and it must submit to the same page
      • An ASPX page may contain:
        • Directives: <%@ Directive %>
        • Server controls: <tag runat=server>
        • Code blocks: <script runat=server>
        • Data binding expressions: <%# %>
        • Server-side comments: <%-- --%>
        • Server-side includes: <!-- #include -->
        • Render code: <%= %> and <% %>
    • Structural Changes (2)
      • Code block – related changes
        • You cannot declare functions inside <% %> tags
        • Declare all your functions and variables inside the server-side <SCRIPT> blocks
          • <Script runat=“server” language=“vb”>
          • dim gVar as String ‘Page level variable
          • private sub MySubRoutine()
          • Label1.Text = gVar
          • End Sub
          • </Script >
    • Structural Changes (3)
      • No Render functions permited
        • Change:
            • <% MyRenderFunction
            • Sub MyRenderFunction() %>
            • <h1> Hi there! </h1>
            • <%end sub%>
        • To:
          • <% Call MyRenderFunction()%>
          • <script runat=“server” language=“vb”>
          • Response.Write(“Hi there!”)
          • </script>
    • Structural Changes (4)
      • New page directives
        • In ASP, directives had to be at the top of the page, but you do not have to do this anymore
        • You can now have multiple directives on the same page
        • Sample page directive:
          • <%@ Page Language=&quot;VB&quot; ContentType=&quot;text/xml&quot; %>
        • See the documents on new page directives
    • Application Configuration Changes
      • ASP.NET application settings are stored in XML configuration files
      • Types of configuration files
        • Machine.config
          • Contains machine-wide settings
        • Web.Config
          • Contains project/application-wide settings
      • Easy programmatic access to the data in these files
      • Some of the settings in the IIS snap-in are ignored
        • For example: application protection level, session state
    • Session Management Changes
      • New session state storage mechanisms
        • InProc – session data stored on local computer (fastest)
        • StateServer – session data stored in a state service that can be located anywhere; ideal for WebFarms (faster)
        • SQLServer – session data stored in Microsoft SQL Server™ (fast)
        • Off – disable session state
      • Session state can be configured using <sessionState> section
      • Can store COM components in session only in InProc
      • Can store managed components in any session state modes
    • Security Related Changes
      • The IIS part of the security remains same
      • New robust and flexible security model is based on the security sections in the configuration files
      • New authentication modes
        • Windows: uses Windows Authentication
        • Forms: uses cookie-based custom logon forms
        • Passport: uses the Microsoft .NET Passport Service
        • None: no authentication
      • Authorization modes permit you to control access to resources:
        • File authorization
        • URL authorization
        • Permit and deny users access to the application
    • Migrating VBScript to Visual Basic .NET
      • No VBScript in ASP.NET — it’s all Microsoft Visual Basic® .NET!
      • Changing the file name extension to .aspx is the first step
      • Visual Basic language changes
        • Option Explicit is now the default
        • No more “variant” type — use type “Object”
        • Method and function calls with parameters now require parenthesis, so change:
        • <% Response.Write “Hi” %> to <% Response.Write (“Hi”) %>
        • By default, arguments are passed by value
        • Arrays are now zero based
    • Visual Basic Language Changes
      • Let and Set are not supported, so change:
        • Set MyObj1 = MyObj2 to MyObj1 = MyObj2
      • No more default properties (except for indexed properties), so change:
      • MyString as string = Textbox1 to MyString as string = Textbox.Text
      • Integer data type is now 32 bits and a Long data type is 64 bits
      • Use structured error handling (try catch block) instead of On Error (On Error still works)
      • Must cast data types explicitly:
      • Response.Write (“Count=“ & CStr(MyCount))
          • or Response.Write(“Count=“ & CType(MyCount, String))
    • Visual Basic Language Changes (2)
      • Must have spaces around “&” while doing string concatenation, so change:
        • x = str1&str2
        • to x = str1 & str2
      • Property Get, Property Set, and Property Let are not supported anymore, so instead use:
        • Public Property MyCount as Integer
        • Get
        • MyCount = InternalValue
        • End Get
        • Set
        • InternalValue = value
        • End Set
        • End Property
    • Migrating JScript to JScript .NET
      • Start by changing the file name extension to .aspx
      • Declare your variables explicitly
      • Microsoft JScript® .NET language changes
        • You can now pass variables by reference
        • “ expando” modifier available to extend user-defined objects
        • Can use COM components directly from JScript .NET
        • Server Object’s methods are case sensitive
        • The Arguments object is not available — use a parameter array instead
        • Functions cannot be redefined
        • For Large pages, move function/method code out of <% %> blocks to <Script runat=“server”> blocks
    • Migrating Applications that Use COM Components
      • COM related changes:
        • ASP.NET uses MTA instead of STA
        • Pages with STA components may or may not perform well
        • Early binding is preferred in ASP.NET
        • Cannot use ASPCOMPAT with WebServices
      • COM Interop
        • Can use all your former COM components in ASP.NET
        • Use ASPCOMPAT keyword if you plan to use existing STA components in ASP.NET
        • Use ASPCOMPAT only when using STA objects or when your COM objects access ASP intrinsic objects
    • COM Objects Migration — FAQ
      • What if the page contains both MTA and STA?
        • Use ASPCOMPAT
      • What if I have a middle tier containing COM objects?
        • Use horizontal or vertical migration strategies
      • What about the performance if I use existing COM objects?
        • Very little overhead if the method does substantial tasks
        • Significant overhead if the method does not do much
    • COM Objects Migration — FAQ (2)
      • What about deploying COM objects used in ASPX pages?
        • If you want to use Server.CreateObject, then there is no change
        • If you use early binding then use the PIA (Primary Interop Assembly) for the COM component and make sure you deploy the PIA on the target server
      • How can I use STA components from XML WebServices?
        • Register the component in COM+ and make sure you are running Windows 2000 SP2
    • Migrating Applications that Use Databases
      • Data access changes
        • ADO (through Interop) can be used, but Microsoft does not recommend it
        • ADO and ADO.NET are quite different
        • ADO.NET is not exactly backward compatible
        • Three main objects in ADO.NET: DataSet, DataReader, and DataAdapter
        • Two built-in managed data providers: SQLClient and OLEDB
        • Built-in designer support for ADO.NET objects in Visual Studio .NET
    • Migrating Applications that Use Databases (2)
      • Strategies
        • Rewrite ADO code in ADO.NET instead of migrating
        • Keep ADO code as a short term approach
        • If you use ADO code in ASP pages, use Primary Interop Assembly for ADO on both the developer box and the server
        • If you need read-only data, use a DataReader
    • Data Access Migration — FAQ
      • What if my application has straight ADO code in ASP pages?
        • Use ASPCOMPAT to use the code as it is (may be slower)
        • Rewrite the data access code to use ADO.NET
      • What if my application has COM objects that use data access?
        • Use the ASPCOMPAT attribute (if component uses STA)
      • What if my database has no managed providers?
        • You can use OLEDB providers in ADO.NET
        • If there are no OLEDB providers, use ODBC managed provider
    • Data Access migration — FAQ (2)
      • What if I have a data access tier?
        • Make these objects call Web Services or managed components
        • Later on, modify the presentation layer to use only .NET middle tier
      • Do I have to package ADO Components during deployment?
        • Make sure your server has MDAC 2.6 installed
        • Make sure you also deploy the PIA for ADODB on the server
    • General Migration Strategy
      • Identify the parts of the application that you have to migrate
      • Plan very carefully and try to have minimal impact on the existing application during the migration
      • In a multi-tier scenario, take the horizontal or vertical approach
        • Horizontal – migrate the whole tier (middle/presentation) at the same time
        • Vertical – migrate some pages, some components, at the same time
      • Decide if you want to reuse existing COM components
    • General Migration Strategy (2)
      • Decide if you want to keep current ADO code for a while
      • Rename the file name extension from .asp to .aspx
      • Make the language-specific changes first
      • Make COM- and database-specific changes
      • Test, test, test
    • Migration Best Practices
      • General
        • If the application is relatively small, consider rewriting
        • If the application is very large, then plan carefully and migrate part by part
        • If you only want to make a syntactic port, then consider only ASPX pages (that is, not using the “code behind” model) and do not make unnecessary changes
        • You do not have to port the whole site at the same time
          • Consider migrating the slow/critical parts
          • Remember, you can run ASP and ASP.NET side-by-side
        • Try to migrate the read-only pages first
        • Write automated tools to do some tasks
    • Migration Best Practices (2)
      • Language related
        • Strongly type all the variables
        • If possible, convert all the On Error statements to try catch blocks
          • Remember that they may not be as easy as they look
        • Convert Include files into assemblies or user controls (.ascx)
        • Use call keyword for function calls and use parenthesis for function and subroutine calls
        • Identify default properties and replace them appropriately
        • Always use Option Explicit
    • Migration Best Practices (3)
      • Data access related
        • If you have a data access tier, move it into .NET
      • COM related
        • Always use early binding
        • Explicitly free resources from code
      • Project management related
        • Keep two code trees while migrating, and make sure to update both of them while adding changes to the existing Web site
        • First try to modify the existing code as it is
          • After you complete this, try to modify the application to use the advantages provided by .NET
    • Migration Best Practices (4)
      • Testing related
        • Update existing links to your Web site/pages because the file name extension is now .aspx
        • Use a link checker to check any broken links, images, paths, and so on
        • Test very well
    • ASP to ASP.NET Compatibility — FAQ
      • How can ASP and ASP.NET co-exist?
        • Because they have different file name extensions (.asp and .aspx)
        • Because they have different application settings (registry and config files)
      • Can they share session and application data?
        • No – w rite custom code or use third-party component
      • What about Global.asa in ASP.NET?
        • In ASP.NET, it is called as Global.asax
    • ASP to ASP.NET Compatibility — FAQ (2)
      • Can I use .NET components from ASP, and COM components from ASP.NET?
        • Yes – use CCW to call managed components from ASP
        • Yes – u se RCW to call COM components from ASP.NET
      • What about the anonymous account in ASP.NET?
        • Remains the same
      • What about the hosting process in ASP.NET?
        • ASP.NET applications run under ASPNET_WP.EXE
        • By default, ASP.NET worker process runs under an account called ASPNET
    • ASP to ASP.NET Compatibility — FAQ (3)
      • Do I need to write code for different browsers?
        • No – ASP.NET produces HTML 3.2 compliant output
      • Can I still use ADO from ASP.NET?
        • Yes – y ou can use ADO through Interop, but ADO.NET is preferred
      • What about Include files?
        • Can be used, but better to convert them to class libraries or user controls (.ascx) instead
      • Can I call ASP pages from ASPX and vice versa?
        • Yes
    • ASP.NET Resources
      • ASP.NET Quick Start Tutorials
      • Authentication in ASP.NET Security
      • ASP.NET Security
      • Session State in ASP.NET
      • ASP.NET Configuration
      • http://www.gotdotnet.com
      • http://www.asp.net
      • http://www.ibuyspy.com
    • Migration Resources
      • Migrating to ASP.NET: Key Considerations
      • Migrating ASP Pages to ASP.NET
      • Converting ASP to ASP.NET
      • Upgrading to Microsoft .NET on GotDotNet
      • Upgrading to .NET on MSDN
      • Upgrading from JScript to JScript .NET
      • Microsoft .NET/COM Migration and Interoperability
      • Q314775 , “INFO: Migrating Visual InterDev Design-Time Controls to ASP.NET”
      • .NET Migration Case Study
      • Thank you for joining us for today’s Microsoft Support
      • WebCast.
      • For information about all upcoming Support WebCasts
      • and access to the archived content (streaming media
      • files, PowerPoint® slides, and transcripts), please visit:
      • http://support.microsoft.com/webcasts/
      • We sincerely appreciate your feedback. Please send any
      • comments or suggestions regarding the Support
      • WebCasts to [email_address] .