asp.net 2.0 - differences dave webster emea technical team [email protected]...
TRANSCRIPT
ASP.NET 2.0 - Differences
Dave WebsterEMEA Technical Team [email protected]/davewebsterMicrosoft Corporation
Who are you?
• ASP 2.0
• ASP Classic?
• PHP?
• ASP 1.1?
• Ruby on rails?
• Cold Fusion?
Overview
• The good and bad with Classic ASP (and PHP)
• Introduction to Microsoft® ASP.NET
• Key changes from ASP to ASP.NET
• Applications that use databases
• ASP to ASP.NET compatibility FAQ
• An introduction to Atlas
3
What do you like about…• ASP Classic/PHP?
– Its free
– Lots of samples
– Deployment is easy
– Your existing code just works
– Living community
What don't you like about…• ASP/PHP
– Not type safe
– Spaghetti code
– Error prone
– Security risks?
• Code base may be old and vulnerable (esp. ASP)
– Can't reuse skills
– Not object Oriented (ASP earlier PHP)
– Lots of code (even if it's someone else's)
• PHP
– Best editors are not free
What concerned you about previous versions of ASP.Net?
• Requires learning a new language – VB.Net looks different– All the samples are in C#
• Everything was compiled into a single binary• Deployment is difficult• Its expensive just to evaluate it• Needs IIS on the machine – can’t use at home or at
work
6
Enter Asp.Net 2.0
• Requires learning a new language – VB.Net looks different it’s still VB– All the samples are in C#. Now also in VB.Net.
• No compile step necessary, save and refresh
• Deployment is easy
• Express edition is free
• Comes with its own limited Web Server
7
ASP.NET Request Flow
RequestRequest
ASPXASPX
engineengine
ParseParse
Instantiate, Instantiate, process, and process, and
renderrender
ResponseResponse
RequestRequest
GenerateGenerate
ResponseResponsePagePage
classclass
InstantiateInstantiate
8
ASP.NET 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 contentOne File Two files. (code-behind model)
Page.aspx Page.aspx Page.aspx.vb
<Tags> + Code
<Tags> Code
9
Visual Studio 2005
Microsoft Visual Studio Professional Edition
Novices
Enthusiasts
Students
Hobbyists
Part-Timers
Professionals
Consultants
Enterprise Devs
Visual StudioTeam System
Visual StudioTeam Architect Edition
Visual StudioTeam Developer Edition
Visual StudioTeam Tester Edition
Architects
Testers
C#Express
VB C++ J# Web
Demo
• Hello world
• Controls
• Accessibility
• Localization
ASP.NET Features
• Life made easy for developers– Visual Studio designer support, rich server
controls, and base class library support– Write code in the language of your choice– Structured error handling– Great debugging and tracing support
12
ASP.NET Features
• Performance, scalability, and reliability– Compiled code means speed– Cache APIs to improve performance and scalability– Built-in support for Web farms and Web gardens– Nonstop availability and protection against
deadlocks, memory leaks, and so on
13
ASP.NET Features
• Easy deployment– Xcopy deployment – Don’t need FPSE– Dynamic updates without interrupting the service – use
FTP– No more registry! Use XML-based configuration files
• More control with the new security model• Flexible session state management• Many other new features
14
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- and application-wide settings• Easy programmatic access to the data in these files
15
Security Related Changes• The IIS part of the security remains same• Use security sections in the configuration files• New authentication modes
– Windows, Forms, None
• Authorization modes permit you to control access to resources:– File authorization – URL authorization– Permit and deny users access to the application
16
VBScript vs. Visual Basic .NET
• No VBScript in ASP.NET — it’s all Microsoft Visual Basic® .NET!
• 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
parentheses, so change:<% Response.Write "Hi" %>to<% Response.Write ("Hi") %>
– By default, arguments are passed by value– Value types and reference types– Arrays are now zero based
17
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
18
Visual Basic Language Changes• Integer data type is now 32 bits and a Long data
type is 64 bits• Use structured error handling (Try-catch block)
instead of OnError (OnError still works)• Must cast data types explicitly:
Response.Write ("Count=" & CStr(MyCount))
orResponse.Write("Count=" & CType(MyCount, String))
19
Visual Basic Language Changes• 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 20
Demo
• VB Language Changes
Applications that Use Databases
• Data access changes– 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• Can be code free
22
• 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 – you can use ADO through Interop, but
ADO.NET is preferred
23
ASP to ASP.NET Compatibility FAQ
Demo
• Atlas
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• http://msdn.microsoft.com/vstudio/express/
25