45
Joe Stagner Joe Stagner ( ( [email protected] [email protected] ) ) Developer Technologist Developer Technologist Microsoft Corporation Microsoft Corporation ASP.NET for PHP ASP.NET for PHP Developers Developers

ASPNET for PHP Developers

Embed Size (px)

DESCRIPTION

ASPNET for PHP Developers

Citation preview

Page 1: ASPNET for PHP Developers

Joe Stagner (Joe Stagner ([email protected]@Microsoft.com))Developer Technologist Developer Technologist Microsoft CorporationMicrosoft Corporation

ASP.NET for PHP ASP.NET for PHP DevelopersDevelopers

Page 2: ASPNET for PHP Developers

Session PrerequisitesSession Prerequisites

Level 200Level 200

Knowledge of PHPKnowledge of PHP

Some familiarity with ASP.NETSome familiarity with ASP.NET

Some familiarity with C#Some familiarity with C#

Page 3: ASPNET for PHP Developers

DemonstrationsDemonstrations

Demo 1 – ASP.NET Event ModelDemo 1 – ASP.NET Event Model

Demo 2 – Validation, Demo 2 – Validation,

Session State & Error Session State & Error HandlingHandling

Demo 3 – Database AccessDemo 3 – Database Access

Demo 4 – AuthenticationDemo 4 – Authentication

Demo 5 – XML in ASP.NETDemo 5 – XML in ASP.NET

Page 4: ASPNET for PHP Developers

AgendaAgenda

Architecture ComparisonArchitecture Comparison

ASP.NET and PHP FunctionalityASP.NET and PHP Functionality

Migration ConsiderationsMigration Considerations

Page 5: ASPNET for PHP Developers

Architecture ComparisonArchitecture ComparisonMicrosoft .NET with Microsoft .NET with ASP.NETASP.NET

PHP pagesrunning onmost majorweb servers

PresentationPresentation

Business Business LogicLogic

DataDataMySQL

PHP andApache

CLRC# AssemblyADO.NET.Can still use COM+Components.

MySQL common, but support for most databases

PHP PlatformPHP Platform

SQL Server 2000

Stored ProceduresOpenXML.

Web FormsServer ControlsCode-Behind.

ASP.NETIIS

Page 6: ASPNET for PHP Developers

Architecture Comparison Architecture Comparison

Analogous Functionality Analogous Functionality

Lower Architectural LevelLower Architectural LevelPlatform Independent Processor/Engine Platform Independent Processor/Engine

A Series of TechnologiesA Series of Technologies

Page 7: ASPNET for PHP Developers

Architecture ComparisonArchitecture Comparison

Both Support OOPBoth Support OOP

PHP (4.x)PHP (4.x)Only Supports Partial EncapsulationOnly Supports Partial Encapsulation

No OverloadingNo Overloading

No abstractionNo abstraction

ASP.NETASP.NETOffers Private, Public, Protected Offers Private, Public, Protected accessibilityaccessibility

Supports overloading and polymorphismSupports overloading and polymorphism

PHP (5) PHP (5) Good OOP SupportGood OOP Support

Page 8: ASPNET for PHP Developers

Architecture ComparisonArchitecture Comparison

CompilationCompilationPHPPHP

Compiled to Zend Opcodes when requestedCompiled to Zend Opcodes when requested

Zend Engine generates and serves HTMLZend Engine generates and serves HTML

ASP.NETASP.NETCompiled to MSIL (Microsoft Intermediate Compiled to MSIL (Microsoft Intermediate Language) on the first requestLanguage) on the first request

MISL processed by the CLR (Common Runtime MISL processed by the CLR (Common Runtime Language) to machine codeLanguage) to machine code

Subsequent requests use that same machine Subsequent requests use that same machine code (no recompilation)code (no recompilation)

Page 9: ASPNET for PHP Developers

Architecture ComparisonArchitecture Comparison

Feature ComparisonFeature ComparisonCoding languageCoding language

Component ModelComponent Model

Type SystemType System

Output CachingOutput Caching

Database AccessDatabase Access

Database OutputDatabase Output

External PackagesExternal Packages

XMLXML

Page 10: ASPNET for PHP Developers

Architecture ComparisonArchitecture Comparison

Feature Comparison (cont.)Feature Comparison (cont.)Eventing Eventing

XML Web ServicesXML Web Services

Session StateSession State

Regular ExpressionsRegular Expressions

DebuggingDebugging

Error HandlingError Handling

IDEIDE

Page 11: ASPNET for PHP Developers

PHPPHPPerl style syntaxPerl style syntax

Loosely typed variable declarationLoosely typed variable declaration

Code Rendering Blocks <?php … ?>Code Rendering Blocks <?php … ?>

ASP.NETASP.NETVB or C# syntaxVB or C# syntax

Strongly typed variable declarationStrongly typed variable declaration

Code Rendering Blocks <% … %>Code Rendering Blocks <% … %>

Code Behind Code Behind

Comparing Syntax and Common TasksComparing Syntax and Common Tasks

Page 12: ASPNET for PHP Developers

HTML Server ControlsHTML Server ControlsMay contain properties, methods, May contain properties, methods, and eventsand events

Tag identifies the control to createTag identifies the control to create

Must contain the ‘runat=server’ Must contain the ‘runat=server’ attributeattribute

Web Server ControlsWeb Server ControlsProvides browser specific HTMLProvides browser specific HTML

Provides an abstract way of creating Provides an abstract way of creating controls that may be rendered in a controls that may be rendered in a browser specific way.browser specific way.

Server ControlsServer Controls

Page 13: ASPNET for PHP Developers

PHPPHPHandles event through the PostBack Handles event through the PostBack mechanismmechanism

May manually detect events with client May manually detect events with client side script.side script.

ASP.NETASP.NETServer Controls invoke server side events.Server Controls invoke server side events.

Event handling happens in through Event handling happens in through ASP.NET on the server.ASP.NET on the server.

Event HandlingEvent Handling

Page 14: ASPNET for PHP Developers

DemoDemo

Programming the Event ModelProgramming the Event Model

Page 15: ASPNET for PHP Developers

Session StateSession State

ViewStateViewState

CookiesCookies

Page StatePage State

Page 16: ASPNET for PHP Developers

ValidationValidation

Validation ControlsValidation ControlsRequiredFieldValidatorRequiredFieldValidator

RegularExpressionValidatorRegularExpressionValidator

CustomValidatorCustomValidator

Client-side ValidationClient-side Validation

Displaying Validation ErrorsDisplaying Validation Errors

ControlToValidateControlToValidate

Page 17: ASPNET for PHP Developers

Session StateSession State

Session State Store ModesSession State Store ModesIn-Process Mode (InProc)In-Process Mode (InProc)

State Server Mode (StateServer)State Server Mode (StateServer)

SQL Server Mode (SQLServer)SQL Server Mode (SQLServer)

ASP.NET’s cookieless feature ASP.NET’s cookieless feature (cookieless=“true”)(cookieless=“true”)

Page 18: ASPNET for PHP Developers

ConfigurationConfiguration

Hierarchy of .config FilesHierarchy of .config Filesmachine.configmachine.config

Web.configWeb.config

XML-basedXML-based

Live changesLive changes

ExtensibleExtensible

Page 19: ASPNET for PHP Developers

Error handlingError handlingTry – Catch – Finally Try – Catch – Finally

Customizing error pagesCustomizing error pages<configuration>

<system.web> <customErrors mode="RemoteOnly" defaultRedirect=“/CustomError.htm"/>

<error statusCode="500" redirect="/error/callsupport.htm"/> <error statusCode="404" redirect="/error/notfound.aspx"/>

</system.web> </configuration>

Application-wide with Global.aspxApplication-wide with Global.aspxprivate void Application_Error(object sender,System.EventArgs e) { // use Request.Url.ToString() to get URL // use Server.GetLastError().ToString() for a Stack Trace // write the error message to the NT Event Log}

Page 20: ASPNET for PHP Developers

DemoDemo

Validation, Session State and Error Validation, Session State and Error HandlingHandling

Page 21: ASPNET for PHP Developers

Data AccessData Access

ADO.NETADO.NET

Dataset objectDataset object

DatabindingDatabinding

Page 22: ASPNET for PHP Developers

DemoDemo

Database Database AccessAccess

Page 23: ASPNET for PHP Developers

Authentication TypesAuthentication Types

ACLACL

URLURL

Authentication ElementAuthentication ElementNoneNone

WindowsWindows

FormsForms

PassportPassport

Page 24: ASPNET for PHP Developers

DemoDemo

AuthenticationAuthentication

Page 25: ASPNET for PHP Developers

Catalog browsingCatalog browsing

Middle tierMiddle tierCall: SqlConnection, SqlDataAdapter and Call: SqlConnection, SqlDataAdapter and SqlCommandSqlCommand

Return: DataSet or SqlDataReaderReturn: DataSet or SqlDataReader

Presentational tierPresentational tierDataBind query results to data controlsDataBind query results to data controls

RepeaterRepeater and and DataListDataList objects objects

ItemTemplate to set presentationItemTemplate to set presentation

Page 26: ASPNET for PHP Developers

XMLXML

PHPPHPUses a SAX parserUses a SAX parser

No native DTD supportNo native DTD support

Numerous third party packages availableNumerous third party packages available

ASP.NETASP.NETSupports DOM parsingSupports DOM parsing

.NET provides support for all W3C .NET provides support for all W3C recommendationsrecommendations

Extensive support for UDDI, WDSL, and Extensive support for UDDI, WDSL, and SOAPSOAP

Page 27: ASPNET for PHP Developers

DemoDemo

Working with XML & XML Web Working with XML & XML Web ServicesServices

Page 28: ASPNET for PHP Developers

Integreted IDEIntegreted IDE

DebuggingDebuggingVisual Studio .NET provides excellent Visual Studio .NET provides excellent ASP.NET debugging tools.ASP.NET debugging tools.

Allows for breakpoint setting in the eventsAllows for breakpoint setting in the events

One debugging session crosses all three One debugging session crosses all three logical tiers (presentation/script, logical tiers (presentation/script, component, and sql)component, and sql)

Page 29: ASPNET for PHP Developers

DeploymentDeployment

XCOPY / Drag ‘n DropXCOPY / Drag ‘n Drop

Windows Installer Windows Installer

Page 30: ASPNET for PHP Developers

ASP.NET Can – PHP Can’tASP.NET Can – PHP Can’t

Component CreationComponent CreationCalling binary .DLLsCalling binary .DLLsSimplifying InteroperabilitySimplifying InteroperabilityRemote InstancingRemote InstancingApplication MultithreadingApplication MultithreadingAsynchronous DependenciesAsynchronous DependenciesMulti Phase TransactionsMulti Phase TransactionsAggregating Multi-Interfaced ObjectsAggregating Multi-Interfaced ObjectsType Encapsulation & AbstractionType Encapsulation & AbstractionObject Scope PromotionObject Scope PromotionStatic Instance AccessStatic Instance Access

Page 31: ASPNET for PHP Developers

Migration ConsiderationsMigration Considerations

Business logicBusiness logicSeparate business logic from presentation Separate business logic from presentation codecode

Create .NET componentsCreate .NET components

PresentationPresentationGenerate PagesGenerate Pages

Use Server ControlsUse Server Controls

.aspx and .cs files.aspx and .cs files

Presentation logic calls .NET componentsPresentation logic calls .NET components

Page 32: ASPNET for PHP Developers

Migration ConsiderationsMigration Considerations

Output cachingOutput cachingCache pagesCache pages

Reduce load on database, web serverReduce load on database, web server

Increased performanceIncreased performance

Fragment CachingFragment Caching

Page 33: ASPNET for PHP Developers

Migration ConsiderationsMigration Considerations

Data cachingData cachingExpiration Expiration

Scavenging Scavenging

File and Key DependenciesFile and Key Dependencies

Page 34: ASPNET for PHP Developers

For More Information…For More Information…

MSDN Web site at MSDN Web site at msdn.microsoft.commsdn.microsoft.com

Other MS web sitesOther MS web siteswww.asp.netwww.asp.net

Page 35: ASPNET for PHP Developers

33rdrd Party Applications Party ApplicationsA broad range of applications on A broad range of applications on ASP.NETASP.NET

Commercial and Non-Commercial Commercial and Non-Commercial licensinglicensing

Fully customizableFully customizable

Initial applicationsInitial applicationsDotNetNuke (portal builder) DotNetNuke (portal builder)

Telligent Community Server Telligent Community Server

Forums, Blogs, GalleryForums, Blogs, Gallery

www.communityserver.org www.dotnetnuke.com

Page 36: ASPNET for PHP Developers

Training & Training & EventsEvents

MSDN Webcasts, MSDN Online MSDN Webcasts, MSDN Online Seminars, Tech-Ed, PDC, Developer DaysSeminars, Tech-Ed, PDC, Developer Days

MSDNMSDNEssential Resources for DevelopersEssential Resources for Developers

Subscription Subscription ServicesServices

OnlineOnlineInformationInformation

MembershipMembershipProgramsPrograms

Print Print PublicationsPublications

Library, OS, Professional, Enterprise, Library, OS, Professional, Enterprise, Universal Delivered via CD-ROM, DVD, WebUniversal Delivered via CD-ROM, DVD, Web

MSDN Online, MSDN Flash, How-To MSDN Online, MSDN Flash, How-To Resources, Download CenterResources, Download Center

MSDN User GroupsMSDN User Groups

MSDN MagazineMSDN MagazineMSDN NewsMSDN News

Page 37: ASPNET for PHP Developers

How-To ResourcesHow-To ResourcesSimple, Step-By-Step ProceduresSimple, Step-By-Step Procedures

Embedded Development How-To ResourcesEmbedded Development How-To ResourcesGeneral How-To Resources General How-To Resources Integration How-To Resources Integration How-To Resources JScript .NET How-To Resources JScript .NET How-To Resources .NET Development How-To Resources .NET Development How-To Resources Office Development Resources Office Development Resources Security How-To Resources Security How-To Resources Visual BasicVisual Basic®® .NET How-To Resources .NET How-To Resources Visual C#Visual C#™™ .NET How-To Resources .NET How-To Resources Visual StudioVisual Studio®® .NET How-To Resources .NET How-To Resources Web Development How-To Resources (ASP, IIS, XML) Web Development How-To Resources (ASP, IIS, XML) Web Services How-To Resources Web Services How-To Resources Windows Development How-To Resources Windows Development How-To Resources

http://msdn.microsoft.com/howtohttp://msdn.microsoft.com/howto

Page 38: ASPNET for PHP Developers

MSDN WebcastsMSDN WebcastsInteractive, Live Online EventInteractive, Live Online Event

Interactive, Synchronous, Live Online Interactive, Synchronous, Live Online EventEventDiscuss the Hottest Topics from Discuss the Hottest Topics from MicrosoftMicrosoftOpen and Free For The General PublicOpen and Free For The General PublicTakes Place Every TuesdaysTakes Place Every Tuesdays

http://www.microsoft.com/usa/webcastshttp://www.microsoft.com/usa/webcasts

Page 39: ASPNET for PHP Developers

MSDN Subscriptions MSDN Subscriptions THE way to get Visual Studio .NETTHE way to get Visual Studio .NETVisual Studio .NETVisual Studio .NET MSDN SubscriptionsMSDN Subscriptions

NE

W

ProfessionalProfessional• Tools to build applications Tools to build applications

and XML Web services for and XML Web services for Windows and the WebWindows and the Web

MSDN ProfessionalMSDN Professional$1199 new$1199 new

$899 renewal/upgrade$899 renewal/upgrade

MSDN EnterpriseMSDN Enterprise$2199 new$2199 new

$1599 renewal/upgrade$1599 renewal/upgrade

MSDN UniversalMSDN Universal$2799 new$2799 new

$2299 renewal/upgrade$2299 renewal/upgrade

Enterprise DeveloperEnterprise Developer• Enterprise lifecycle toolsEnterprise lifecycle tools• Team development supportTeam development support• Core .NET Enterprise Core .NET Enterprise

ServersServers

Enterprise ArchitectEnterprise Architect• Software and data modelingSoftware and data modeling• Enterprise templatesEnterprise templates• Architectural guidanceArchitectural guidance

Page 40: ASPNET for PHP Developers

Where Can I Get MSDN?Where Can I Get MSDN?

Visit MSDN Online atVisit MSDN Online atmsdn.microsoft.commsdn.microsoft.com

Register for the MSDN Flash Email Register for the MSDN Flash Email Newsletter at Newsletter at

msdn.microsoft.com/flashmsdn.microsoft.com/flash

Become an MSDN CD Subscriber at Become an MSDN CD Subscriber at msdn.microsoft.com/subscriptionsmsdn.microsoft.com/subscriptions

MSDN online seminarsMSDN online seminars

msdn.microsoft.com/training/seminarsmsdn.microsoft.com/training/seminars

Attend More MSDN EventsAttend More MSDN Events

Page 41: ASPNET for PHP Developers

MS PressMS PressEssential Resources for DevelopersEssential Resources for Developers

Microsoft® Visual Studio® .NET is here!Microsoft® Visual Studio® .NET is here!This is your chance to start building the next big This is your chance to start building the next big

thing. Develop your .NET skills, increase your thing. Develop your .NET skills, increase your productivity with .NET Books from Microsoft Press®productivity with .NET Books from Microsoft Press®

www.microsoft.com/mspresswww.microsoft.com/mspress

Page 42: ASPNET for PHP Developers

Become A Microsoft Become A Microsoft Certified Solution Certified Solution DeveloperDeveloper

What Is MCSD?What Is MCSD?Premium certification for professionals who Premium certification for professionals who design and develop custom business solutionsdesign and develop custom business solutions

How Do I attain MCSD Certification?How Do I attain MCSD Certification?It requires passing four exams to prove It requires passing four exams to prove competency with Microsoft solution architecture, competency with Microsoft solution architecture, desktop applications, distributed application desktop applications, distributed application development, and development toolsdevelopment, and development tools

Where Do I Get More Information?Where Do I Get More Information?For more information about certification For more information about certification requirements, exams, and training options, requirements, exams, and training options, visit visit www.microsoft.com/mcpwww.microsoft.com/mcp

Page 43: ASPNET for PHP Developers

TrainingTrainingTraining Resources for DevelopersTraining Resources for Developers

Course Title:Course Title: Course Number:Course Number:

Availability:Availability:

Detailed Syllabus: Detailed Syllabus: www.microsoft.com/traincertwww.microsoft.com/traincert

Course Title:Course Title: Course Number:Course Number:

Availability:Availability:

Detailed Syllabus: Detailed Syllabus: www.microsoft.com/traincertwww.microsoft.com/traincert

To locate a training provider for this course, please accessTo locate a training provider for this course, please access

www.microsoft.com/traincert Microsoft Certified Technical Education Centers Microsoft Certified Technical Education Centers

are Microsoft’s premier partners for training servicesare Microsoft’s premier partners for training services

Page 44: ASPNET for PHP Developers

Finding me.Finding me.

[email protected]@Microsoft.com

http://www.ManagedCode.comhttp://www.ManagedCode.com

http://blogs.msdn.com/JoeStagnerhttp://blogs.msdn.com/JoeStagner

http://www.MSDNEvents.comhttp://www.MSDNEvents.com

Page 45: ASPNET for PHP Developers