ASP.Net - McGraw

Programming the Web
Using ASP.Net
Chapter 1:
Dave Mercer
© 2004 by The McGraw-Hill Companies, Inc. All rights reserved.
1. Briefly explain where
Active Server Pages
(ASP) originated
2. Describe how ASP
works in a Web page
3. Understand how ASP
and ASP.Net differ
4. Download ASP.Net
executables on the
Microsoft site
5. Check your server to
see if ASP or ASP.Net
is loaded
6. Create a simple ASP
application manually
7. Run your ASP
8. Review VS.Net features
9. Create the basis for an
ASP.Net application from
a VB.Net template
10. Discuss the fundamental
file types for ASP.Net
Web Applications, ASP, and
Active Server Pages.Net
• Active Server Pages.Net consists of:
– Microsoft’s Active Server Pages technology
– Microsoft’s .Net Framework technology
• The name ASP reflects how the technology
makes Web pages “active” via programming
running on the server.
• The .Net Framework technology is a
foundation for developing applications that
work well over the Internet.
What is ASP.NET?
• ASP.Net is a technology designed to simplify
the creation of dynamic Web applications and
XML Web Services.
• ASP.Net is Microsoft’s next generation of
Active Server Pages (ASP), which relies on
the .Net Framework.
• Neither ASP nor ASP.Net is a programming
language, but developers familiar with them
know that they are accessed via
programming language calls.
How ASP and ASP.Net are Processed
• In ASP, you can write code directly between
HTML or include HTML in your responses.
• In ASP.Net, you create the Web page part of
it in one file (very similar to a standard Web
page written using HTML), and in another file
(called the codebehind file) you write
programming code.
• This separation of the display from the
processing is one of the great improvements
of ASP.Net over ASP.
Sample ASP Code
To respond to user input, you might
<head><title>My Web Page</title></head>
<% Response.Write "<b>Hello</b>" %>
Sample ASP Code with VBScript
This example accepts form input and
responds accordingly:
If Request.Form("name") = "Jim" Then
Response.Write "Hello"
Response.Write "Goodbye"
End If
Web Application Development
Application Development:
Getting Started
• Applications, whether Windows or Web, do a
few basic functions: accept input, process
data, and produce output.
• Applications intended for use by humans
have a user interface, while applications
intended for use by machines have interfaces
that may be difficult for people to use.
• The primary considerations developers face
are size, speed, reliability, and security.
Application Development:
The Project Plan
• The first step in creating an application from
an idea is to build a project plan.
• For business applications, the project plan
should outline the background of the idea, the
business need, how it will integrate into
existing business processes, etc.
• The project plan should also contain a
proposed development solution.
• From that point the project plan is a working
document that may be modified.
Sample Business Application
• A company that sells cruise ship packages
could use a Web-based application that:
– Advertises available cruises to users
– Provides them an opportunity to register as a
group for specific cruises
– Accepts payments online
– Tracks the number of registered users in their
– Notifies users when they are eligible for discounts
Application Programming Tools
• While code can be written with simple text
editing tools, and a compiler may be required,
developing applications with only these tools
is no longer considered very efficient.
• For many years, application developers have
been relying more and more on specialized
application development tools.
• Tools include Integrated Development
Environments (IDEs), specialized source
code editors, debuggers, and template files.
What Does ASP.Net Do?
• ASP.Net isn’t a standalone application
program. By itself, ASP.Net is just part of the
.Net Framework.
• The objects in ASP.Net are available for use
in ASP.Net Web Applications. ASP.Net
includes a number of objects that simplify
user interactions across the Web, such as the
Request and Response objects.
• ASP.Net also includes a facility for writing
code that runs at the application level.
ASP.NET Objects
• There are quite a few objects in ASP.Net that
will be familiar to developers who’ve written
Web applications with ASP:
Developing Web Applications
• Web applications follow a different
development and usage pathway than static
Web sites:
– The application developers incorporate elements
of the site’s design specifications into all the pages
the user sees.
– The server responds to user requests by running
code, connecting to databases, processing user
input, and creating responses containing HTML,
text, and graphics.
– What one user sees may be entirely different from
what another user sees.
Using ASP.Net Objects
• With ASP.Net objects, a working knowledge
of HTML, and some Visual Basic .Net
programming, we could create an application
that does the following:
– Check to see what browser the user is using
– Deliver a home page coded in HTML
– Set a cookie on the user’s browser that
distinguishes them from other users
– Capture values submitted by the user from an
HTML form (or from a link they clicked)
– Perform data processing functions.
The Relationship Between Computers,
Servers, and Applications
Hosting Web Applications
• A Web server’s hardware and software must
be very robust. Server computers often
contain multiple processors and a large
amount of RAM, as well as plenty of Hard
Disk Drive space.
• Sometimes servers have a RAID
(Redundant Array of Inexpensive Drives)
system for redundant data storage, and
sometimes the servers are grouped into
“server farms,” in which multiple servers
serve a single application.
Developing Web Applications
• Developers often use the language (or
languages) they are most familiar with to
write the processing logic for Web
• Languages such as VBScript (often used with
ASP), PHP and Perl, Visual Basic.Net and
C#, C++, and Python are commonly used to
build Web application programming logic.
• ASP.Net can be used in conjunction with
many of these languages.
VS.Net Features
• VS.Net contains visual tools that approximate
what your applications are going to look like
in use. You can use VS.Net to drag and drop
elements onto your application forms.
• You can also format, arrange, size, and align
elements on your forms with your mouse, and
change their properties in the Properties
• VS.Net also contains code editors suited to
specific types of code, such as HTML, XML,
VB.Net, and C#.
Opening VS.Net
VS.Net: The Options Dialog Box
VS.Net Without the Start Page
VS.Net: The File Menu
VS.Net: The Edit Menu
VS.Net: The Find in Files Dialog Box
VS.Net: The Look In Dialog Box
VS.Net: The View Menu
VS.Net: The Server Explorer
VS.Net: The Customize Toolbox
Dialog Box
VS.Net: The Add-In Manager
Dialog Box
VS.Net: The Customize Dialog Box
VS.Net: The Options Dialog Box
on the Environment Node
VS.Net Editors and Other Tools
• Because it is an Integrated Development
Environment (IDE), Visual Studio.Net
contains a number of editors and designers:
The Text and Code Editor
The HTML Designer
The XML Designer
Debugging Tools
• VS.Net also contains a number of powerful
tools for assisting with the debugging
Creating an ASP.Net Web Application
in VS.Net
• A new application under development is
contained in a Solution. A Solution is simply
a file that serves as a reference point for all
the folders, files, and other resources making
up the application.
• Inside a Solution, individual chunks of
processing logic called Projects are
contained. Each project should be logically
self-sufficient, but what goes into a project is
up to you. Projects contain files and folders
related to the functionality they possess.
The ASP.Net Web Application Template
• When you create a new Project using the
Visual Basic Projects ASP.NET Web
Application template, several files and folders
are created automatically:
The End