Introducing ASP+ - 4GuysFromRolla.com

Download Report

Transcript Introducing ASP+ - 4GuysFromRolla.com

Introducing ASP+
Scott Mitchell
[email protected]
http://www.4GuysFromRolla.com/
http://www.ASPMessageboard.com/
http://www.ASPFAQs.com/
The Evolution of the Web
Static Web Pages
Content was static. To
alter the look and feel of a
Web page, a programmer
had to physically alter the
contents of the page itself.
The static nature of the
Web at this time removed
any possibility of a user
interacting with a Web site
or interaction among Web
sites.
Performance was great and
development easy, but the
Web lacked any real
usability.
Dynamic Scripts
Dynamic scripts allowed for
user interaction with a Web
site. Web content could be
dynamically generated based
on a number of variables,
such as user input. Allowed
for the Web to serve as an
application medium.
Development was anything
but easy. The scripting
nature of development led to
poor programming practices
and “messy” code. Also,
interaction among Web sites
was possible, but limited and
difficult.
Distributed,
Compiled Programs
Web pages are actual,
programs created using
object-oriented programming
techniques. These programs
are compiled instead of
interpreted like the scripts of
the past.
A focus on Inter-Web server
communication allows
developers to build truly
distributed applications on
the Web.
Problems with ASP Today
• Nasty code - content and code are helplessly mixed as code
snippets are sprinkled around HTML blocks.
• Deploying an ASP application is difficult, potentially
requiring setting changes to the IIS metabase and
registration of various COM components.
• Common tasks, such as server-side form validation,
displaying database results, caching data, user
authentication, uploading binary files, etc., are difficult.
• Scripting languages offer poorer performance and
encourage more spaghetti-like code than their compiled
counterparts.
• Terrible (terrible!!!) debugging support…
ASP+ to the Rescue!
• ASP+ pages are created with the syntax of modern,
compiled programming languages - either VB (not
VBScript), JScript.NET, C#, or others.
• The registry is no more. Components no longer need to be
registered. Deployment is as simple as XCOPY
• ASP+ provides several, customizable, server-side controls
for common tasks: validation, file upload, database display,
etc.
• ASP+ provides mechanisms for inter-Web server
communication, regardless of the Web server or platform.
• Exceptional debugging tools and options.
The Makeup of ASP+
ASP+ Web
Pages
ASP+ Web
Services
ASP+ Application Layer
ASP+ Web Pages
• These serve the same purpose as ASP pages today:
a dynamic Web page users can visit via the
Internet.
• ASP+ pages have a .aspx extension, and are text
files, just like ASP pages. In fact, they can be
created to look remarkably like ASP. (Show
demo1.aspx…)
• ASP+ pages do not support VBScript. Rather,
pages are created with full-blown VB 7 (or
JScript.NET or C#).
Changes from VB6 to VB7
• No more default properties for objects:
objRS(“columnName”) will generate an error, must
use: objRS.Fields(“columnName”).Value
• As a consequence, Set and Let are no longer supported.
• All calls to subroutines must have parenthesis
• Variables can be dimensioned and initialized
simultaneously: Dim i as Integer = 4
• Error handling now uses Try … Catch … Finally
blocks as opposed to On Error Goto.
• VB7 is (finally) a real OOP language. Now possible to use
polymorphism and true inheritance.
Changes from ASP Coding Styles
to ASP+ Coding Styles
• All functions and subs must exist in <SCRIPT
RUNAT=“server”> blocks (functions cannot
exist in the inline code (<% … %>)).
• ASP+ design encourages use of post-back forms
• ASP+ offers server controls. These controls
provide an object model developers can program
against.
• ASP+ pages are designed to be event-driven as
opposed to procedural-based.
ASP+: Write Less Code
• Collecting and acting on user input… a
comparative look at ASP and ASP+
(create/run demo)
• Note the use of HTML server controls in the
ASP+ page. These are created by adding
the runat=“server” property to
standard HTML tags…
• Note that we can wire up events in the
server controls
Server-Side Validation Example
• With ASP, server-side validation was oftrepeated and a ton of code…
• ASP+ introduces a number of Validation
controls to ease the task of validating form
input.
• Show ValidationDemo.aspx
• For more info, visit:
http://www.4guysfromrolla.com/webtech/090200-1.shtml
Web Services: Inter-Server
Communication
SERVER
CLIENT
XML
XML
XML
XML
SERVER
SERVER
XML
HTML
CLIENT
XML
XML
SERVER
Creating Web Services with
ASP+
• Creating Web Services with ASP+ is as simple as
creating a class (show Math.asmx demo).
• Web service files have an .asmx extension.
• ASP+ creates a default description page for a
given .asmx file (show demo by visiting
http://localhost/aspugtalk/Math.asmx).
• An .asmx files SDL (service description language)
can be viewed by visiting the .asmx file and
appending ?sdl to the QueryString.
Inter-Server Communication
Via HTTP Protocol, a Discovery
request is sent (DISCO)
SERVER
INTIATING
COMMUNICATION
Server returns Service Description
Language (SDL), describing Web service
Sends SOAP Request in format
specified in SDL
Sends SOAP Response,
communications complete
SERVER
RECEIVING
COMMUNICATION
REQUEST
Calling a Web Service from an
ASP+ Page
• A proxy class must be created based on the Web service’s
SDL. This task can be automated by
WebServiceUtil.exe (show Proxy class creation
demo)
• This proxy class must then be compiled into a DLL (show
compilation of proxy class) and moved into the \bin
directory
• The Web service can then be accessed programmatically
from an ASP+ page (demo: show
AccessMathProxy.aspx)
In Conclusion...
• ASP+ is an entirely new way to create interactive,
distributed Web applications.
• ASP+ enables developers to write more powerful
applications with fewer lines of code.
• ASP+ addresses many of the disadvantages of
ASP.
• ASP+ Web services allow for developers to create
truly distributed applications running over
standard protocols.
To Learn More about ASP+
• Download the pre-beta bits at:
http://msdn.microsoft.com/net/
• Pick up a copy of Wrox’s A Preview to ASP+
(Anderson, Homer, Howard, and Sussman)
• Visit the many great ASP Web sites:
4GuysFromRolla.com, ASPFree.com,
ASP101.com, ASPNG.com
• Have your ASP+ Questions Answered at:
ASPMessageboard.com, ASPLists.com