WEB320: Migrating ASP.NET 1.x Applications to ASP

Download Report

Transcript WEB320: Migrating ASP.NET 1.x Applications to ASP

WEB320
Migrating ASP.NET 1.x
Applications to ASP.NET 2.0
Stefan Schackow
Program Manager
Web Platform and Tools Team
Microsoft Corporation
Agenda
Migrating from Microsoft ASP.NET 1.X
to ASP.NET 2.0
Microsoft Visual Studio 2003 to Visual
Studio 2005 (RTM)
Migrating from ASP.NET 1.X to
ASP.NET 2.0
ASP.NET 1.X to ASP.NET 2.0
Goal: Easy to upgrade from V1.1 to V2.0
We have minimized breaking changes
New migration functionality added postBeta2
No OS upgrade required
Runs on Microsoft Windows 2000 & IIS 5.0
Runs on Microsoft Windows XP & IIS 5.1
Runs on Microsoft Windows Server 2003 &
IIS 6.0
ASP.NET 1.X to ASP.NET 2.0 Beta 2
ASP.NET 1.1 & 2.0 can be installed on
same machine
Installing V2.0 on V1.1 server
Always preserves existing V1.1 mappings
New MMC tab to easily switch versions
Existing ASP.NET 1.1 applications can
run on top of ASP.NET 2.0
Issue Tracker – V1.1
Issue Tracker – V1.1 version running
on top of ASP.NET 2.0 post-Beta 2
ASP.NET 1.X to ASP.NET 2.0 Beta 2
Forms Authentication
Works across both ASP.NET versions
ASP.NET 2.0 uses AES encryption by
default
Tweak <machineKey /> to change this
Sharing Forms
Authentication Tickets
ASP.NET 1.X to ASP.NET 2.0
New ASP.NET reserved directory names
(App_)
New naming convention for protecting directories
Avoid naming directories with this prefix
ASP.NET Reserved directories
/Bin – Reserved for assemblies. Same as 1.0 & 1.1
/App_Code – Reserved for code
/App_Data – Reserved for data (*.mdf, .xml, etc.)
/App_Themes – Reserved for theme files (.skin)
/App_WebReferences – Reserved for .wsdl files
/App_LocalResources – Reserved for local page resources
/App_GlobalResources – global resources
ASP.NET 1.X to ASP.NET 2.0
XHTML compliance
XHTML compliant markup is now emitted
by default
Good for standards compliance, but can
break some UI
<xhtmlConformance mode=“”/>
Defaults to mode=“Transitional”
Can set mode=“Legacy” or “Strict”
Recommend updating pages to be XHTML
compliant long-term
ASP.NET 1.X to ASP.NET 2.0
Other XHTML issues:
New pages include a DOCTYPE directive
indicating XHTML 1.0 Transitional
compliance
Can cause rendering problems
Update your HTML to be XHTML compliant
ASP.NET 1.X to ASP.NET 2.0
Well known client-side script files are
now encapsulated as resources
.js files are now referenced:
WebResource.axd?a=s&amp;r=WebUIValidation.js
Hand-editing WebUIValidation.js file will
no longer work
Use expanded client-side scripting
support instead
ASP.NET 1.X to ASP.NET 2.0
Potential for naming collisions
2,000+ new classes in V2.0
Common name collisions: Membership, Roles,
Theme
Does not affect compiled binaries
CLR automatically picks the correct type
Collisions will affect you only if you re-compile
ASP.NET 1.X to ASP.NET 2.0
Identify collision candidates today
Can use fully qualified class names
(e.g., MyProject.Membership instead of
Membership)
Or use an alternative class name
Visual Studio 2003 to
Visual Studio 2005 (RTM)
Visual Studio Conversion
Visual Studio 2005 makes
significant changes to web
projects
Provides much more flexibility for web scenarios
Key Benefits
No more project file required
Web projects no longer compiled into single DLL
Can update pages/code while using the debugger
No need to re-compile when making changes
Significantly cleaner code-behind model
Web projects can be written in multiple languages
Visual Studio Conversion
Visual Studio 2005 converts existing
Visual Studio 2003 projects on open
One way conversion (cannot open in
Visual Studio 2003 afterwards)
Always enable backup option as part of
upgrade wizard
All conversion changes are logged
Visual Studio Conversion
When running under source control:
Move project to new location on disk
Open project and run the conversion
wizard
Check back into source control
Issue Tracker – File Structure
after Conversion
Visual Studio 2005 Conversion
New Code-Behind Model
Visual Studio no longer
generates/modifies code in your codebehind
Control definitions use new partial class
feature of V2 compilers
Still enables definition of custom base
pages + control classes
Visual Studio 2005 Conversion
Syntax differences:
ASP.NET 1.1 page definition
<%@ page codeBehind=“webform1.aspx.cs”
inherits=“WebForm1” %>
ASP.NET 1.1 code-behind class definition
public class WebForm1 : System.Web.UI.Page
ASP.NET 2.0 page definition
<%@ page codeFile=“webform1.aspx.cs”
inherits=“WebForm1” %>
ASP.NET 2.0 code-behind class definition
public partial class WebForm1 :
System.Web.UI.Page
Issue Tracker – After Running
the Conversion Wizard
Visual Studio 2005 Conversion
New dynamic compilation model:
Monolithic code-behind assembly is no
longer used
Pages are compiled on-demand into separate
assemblies
Lead to some problems in Beta 2 and
earlier
Based on customer feedback – more
“smarts” built into conversion wizard
Smoother migration for RTM!
Visual Studio 2005 Conversion
Post-Beta 2 changes to conversion
wizard
Moves non-page type definitions out of
code-behind and into App_Code
Cross-file class references continue to
work
MyControl ctl = (MyControl)
Page.LoadControl(“ctl.ascx”);
Calls to Type.GetType are adjusted
Cross File Class References
Visual Studio 2005 Conversion
ASP.NET 2.0 introduce pre-compilation
Compiles source code into assemblies
Deploy only pages and assemblies
No source ends up on the server
Similar function to compilation from 1.1
Works with new dynamic compilation
model
Visual Studio 2005 Conversion
Can pre-compile with:
aspnet_compiler.exe command line tool
“Publish Website” menu option within
Visual Studio 2005
Two choices when pre-compiling:
All .aspx markup is removed
All .aspx markup preserved
Application Pre-Compilation
Session Summary
ASP.NET V1.1 and V2.0 run side-by-side
on same server
No need to migrate apps in order to start
using V2.0
New conversion wizard in RTM makes
migration even easier
Things to-do today:
Start making HTML markup XHTML compliant
Avoid class naming conflicts with new V2.0
features now where possible
Compatibility DevLabs!
Also in Redmond, WA
June 27-30th
July 25th-28th
No Cost to Attend (you cover your T&E)
Drop by Web Cabana afterwards for more
info
Your Feedback
is Important!
Please Fill Out a Survey for
This Session on CommNet
© 2004 Microsoft Corporation. All rights reserved.
This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.