|
|
|
|
|
The evolution of the Web. |
|
Classic ASP overview – its strengths and
weaknesses. |
|
Time for something new: an examination of
Microsoft’s .NET Strategy. |
|
ASP.NET to the Rescue! |
|
Comparing and Contrasting ASP.NET and classic
ASP. |
|
For more information… |
|
|
|
|
|
|
|
Low cost of entry |
|
Quick and easy to learn for experienced
developers and new developers alike. |
|
Can create very useful Web applications in a
relatively short amount of time. |
|
An active ASP community |
|
Many, many great classic ASP books, Web sites,
training classes, and conferences. |
|
|
|
|
Script-based technology used, leading to poorer
performing, less readable code than a compiled counterpart. |
|
Encouraged developers to shamelessly intermix
code (script) and content (HTML). |
|
Difficult to debug. |
|
Lacked modern programming features, such as
try…catch exception handling, true object-orientation, etc.) |
|
|
|
|
ASP.NET, as we’ll shortly see, fixes all of
these problems inherent in classic ASP! |
|
|
|
Before we look at ASP.NET, specifically, let’s
first turn our attention to Microsoft’s .NET Strategy. |
|
|
|
|
|
In July 2000, Microsoft announced their .NET
Vision at their Professional Developer Conference (PDC). |
|
The main “components” of .NET include: |
|
A runtime system (the Common Language Runtime,
or CLR) |
|
A large set of classes that serve as an API for
program’s run through the CLR (commonly referred to as the .NET Framework
classes, or the .NET SDK). |
|
New programming languages. |
|
|
|
|
Whenever a .NET program is executed, it is fed
into the CLR, which executes the program. |
|
The code expected by the CLR needs to be in a
special intermediate language (MSIL, Microsoft Intermediate Language). |
|
So, “compilers” like VB.NET turn source code
into this MSIL. This MSIL code is
like a high-level, architecture independent assembly language. |
|
|
|
|
When the CLR first runs a .NET program, it must
convert this abstract high-level assembly language into platform-specific
code (referred to as Just-In-Time (JIT) compilation). |
|
This JITed copy can then be run by the CLR each
time the program needs to be run. |
|
|
|
|
|
|
The .NET Framework contains a plethora of
developer libraries that insulates the OS from the developer. |
|
These libraries are broken down into hundreds of
classes grouped in logical namespaces, where each namespace separates a
different set of classes. |
|
The .NET Framework is similar in concept to the
Win32 API, except the .NET Framework is OO-based and sensibly arranged with
helpful documentation. |
|
|
|
|
|
ASP.NET and the inherent server controls are
classes in the .NET Framework. The System.Web
namespace encapsulates the classes used by ASP.NET. |
|
This means that you can access and utilize .NET
classes from within an ASP.NET page, meaning through an ASP.NET Web page
you can do: |
|
|
|
= File Uploads = Image manipulations |
|
= On the fly (de|en)cryption |
|
= Systems-level activities (Event log, perf. mon., etc.) |
|
|
|
|
|
To create .NET programs, you need to use a .NET
programming language (one that compiles to MSIL and uses the .NET Framework
classes). Such languages include: |
|
= VB.NET = C# |
|
= JScript.NET = MS C++ .NET |
|
= Perl.NET = COBOL.NET |
|
|
|
|
|
|
|
VB.NET introduces many new modern concepts into
VB: |
|
Try … Catch exception handling |
|
True OOP |
|
Short-circuit Boolean operators, variable
initialization, standard array base (0), etc. |
|
VB.NET has a handful of “breaking” changes: |
|
No more default properties |
|
Set/Let support dropped |
|
Subs require parenthesized parameters |
|
|
|
|
|
|
|
|
'Create an ArrayList |
|
Dim myArrayList as New ArrayList() |
|
myArrayList.Add("ASP.NET") |
|
myArrayList.Add("is") |
|
myArrayList.Add("cool!") |
|
Response.Write(GetRandomWord(myArrayList)) |
|
|
|
Function GetRandomWord(myAL as ArrayList) |
|
Dim rndNumber as New Random() |
|
Return
myAL(rndNumber.Next(myAL.Count)) |
|
End Function |
|
|
|
|
|
Microsoft’s newest language offering. |
|
Similar to Java in syntax and semantics: |
|
Case sensitive |
|
Statements delimited by semicolons |
|
Blocks delimited by curly braces |
|
Like every .NET language, very OO. |
|
|
|
|
// Create an ArrayList |
|
ArrayList myArrayList = new ArrayList(); |
|
myArrayList.Add("ASP.NET"); |
|
myArrayList.Add("is"); |
|
myArrayList.Add("cool!"); |
|
Response.Write(GetRandomWord(myArrayList)); |
|
|
|
string GetRandomWord(ArrayList myAL) |
|
{ |
|
Random rndNumber = new Random(); |
|
return
myAL[rndNumber.Next(myAL.Count)]; |
|
} |
|
|
|
|
|
|
VB.NET and C# both rely on the classes in the
.NET Framework to accomplish their tasks. |
|
Therefore, essentially anything you can do with
C#, you can do with VB.NET. |
|
Programs written in C# and VB.NET are relatively
equal in performance. |
|
Therefore, choose the programming language that
you and your team knows best! |
|
|
|
|
|
Realize that every data type (int, string,
object, etc.) is defined as a class in the .NET Framework. |
|
That means an int in C# and an Integer in VB.NET
are the same thing – an instance of the Int32 class in the .NET Framework. |
|
Since all .NET languages: |
|
Compile to standard MSIL |
|
Use the same data type definitions |
|
components written in one language can be used in another. |
|
|
|
|
ASP.NET solves for many of the disadvantages in
classic ASP. |
|
ASP.NET Web pages are compiled .NET programs
created by modern .NET programming languages (VB.NET, C#, JScript.NET,
Perl.NET, etc.) |
|
ASP.NET provides excellent debugging options and
opportunities, especially through tools like Visual Studio .NET |
|
|
|
|
|
ASP.NET encourages separation of code and
content (HTML) in many ways: |
|
The use of Code-behind pages which physically
separate the code from the content. |
|
Use of “server controls,” which provide VB-like
control functionality through a Web page.
(John’s talk next will address server controls in great detail!) |
|
|
|
|
|
|
ASP.NET is comprised of two major areas: ASP.NET
Web pages and ASP.NET Web services. |
|
ASP.NET Web pages are akin to classic ASP pages
– Web surfers visit them through a browser and are returned valid HTML. |
|
ASP.NET Web services provide for inter-Web
server communications. This allows
an ASP.NET Web page (or a stand-alone application) to access a remote
program to obtain information. (More
on this topic in tomorrow’s talk on Web services.) |
|
|
|
|
ASP.NET Web pages and Web services are compiled
programs. So when a user visits one
of your ASP.NET Web pages, an actual “program” is being executed – the
ASP.NET Web page. |
|
These Web pages and Web services are compiled
on-demand, meaning that when a Web page or Web service is first visited, it
is compiled. From then on, a cached
version (using disk-based caching) of the intermediate code is referenced. |
|
|
|
|
|
|
|
|
|
Need to install the .NET Framework |
|
Only runs on Windows 2000 and Windows XP Pro
(requires that IIS 5.0+ be installed). |
|
The .NET Framework is freely available to
download from http://www.asp.net/ |
|
Once the .NET Framework has been installed you
can create ASP.NET pages simply by creating a file (using your favorite
editor (Notepad / Visual Studio, etc.) with a .aspx extension in a Web
directory (I.e., C:\InetPub\wwwroot\). |
|
|
|
|
ASP.NET and Classic ASP can run side-by-side on
a Web server. That is, you can have
ASP.NET Web pages and classic ASP pages running on your Web site. |
|
One of .NET’s goals is to provide side-by-side
functionality, meaning you should be able to run ASP.NET v2.0 and v1.0 on
the same Web server at the same time (whenever ASP.NET v2.0 comes out, that
is!). |
|
|
|
|
ASP.NET Web Pages can be created to look just
like classic ASP pages. Show SimpleASP.NET.demo.aspx. |
|
Note that when we run this demo, there is a
slight delay. The .NET Framework is
actually running an instance of the VB.NET compiler! This delay only occurs when the page is
loaded for the first time after it is created or a change to the source
code has occurred. |
|
Also note that ASP.NET Web pages output regular
HTML, just like classic ASP pages. |
|
|
|
|
ASP.NET Web pages are actual, OOP programs,
consisting of a class derived from the Page class in the .NET Framework. |
|
ASP.NET pages can be coded to handle the Page
class events (the most commonly used Page class event handler you’ll create
is for the Load event, which fires when an ASP.NET page is visited). |
|
ASP.NET pages ideally will contain server-side SCRIPT
blocks instead of in-line (<% … %>) script. |
|
Show ProperASP.NET.demo.aspx |
|
|
|
|
|
There are a plethora of .NET Web sites: |
|
http://aspnet.4GuysFromRolla.com |
|
http://www.asp101.com |
|
http://www.15Seconds.com |
|
http://www.asp.net |
|
http://www.aspnextgen.com |
|
http://www.aspalliance.com |
|
There are many newsgroups and listservs and
online forums as well: |
|
http://www.aspfriends.com |
|
http://www.aspmessageboard.com |
|
|
|