Documente Academic
Documente Profesional
Documente Cultură
Question: Which Microsoft .NET technologies does your workplace currently use?
CD Content
Microsoft .NET is a development model that you can use to create platform-independent and device-independent
software. You can also use the .NET Framework to make data available over the Internet. The .NET Framework is the
infrastructure of Microsoft .NET.
Components of Microsoft .NET
Microsoft .NET is built from the ground up on open architecture and you can use it to build and run the next
generation of Microsoft Windows ® and Web applications. The goal of Microsoft .NET is to simplify the development
of Web and other applications.
Microsoft .NET can include the following technologies:
The .NET Framework. The .NET Framework provides a programming model that enables developers to build
Windows and Web applications and XML Web services.
Servers. Microsoft .NET provides an infrastructure to integrate, run, operate, and manage .NET-Framework
solutions on servers such as Microsoft Windows Server 2003™ and Microsoft SQL Server™.
Clients. Microsoft .NET enables developers to deliver a comprehensive user experience across a family of devices
such as mobile devices, Web browsers, and personal computers.
Question: You have been asked to build a new distributed and service-oriented Web application in a Microsoft
Windows ® environment. Which technologies may be suitable for this new application?
CD Content
The .NET Framework provides the necessary compile-time and run-time foundation to build and run Microsoft .NET-
based applications.
The .NET Framework
The .NET Framework consists of different components that help you to build and run Microsoft .NET-based
applications:
Operating System. The .NET Framework must run on an operating system. The supported operating systems for
the .NET Framework version 3.5 are Microsoft Windows Server ® 2003, Windows Vista™, and Windows XP.
Common Language Runtime. The CLR simplifies application development, provides a robust and secure execution
environment, supports multiple languages, and simplifies application deployment and management. The CLR
environment is a managed environment, which provides common services such as garbage collection and security.
By using the CLR, you can develop a Microsoft .NET solution by using the programming language of your choice.
The .NET compiler then transforms your source code and creates a managed module, which the CLR on the client
computer can execute.
Windows Forms, which provides the functionality to develop executable applications that run on client computers.
ASP.NET AJAX, which enables you to create more efficient and interactive Web applications.
CD Content
For many years, developers have used ASP technology to build dynamic Web pages. Similar to ASP, ASP.NET runs on
a Web server and provides a way for you to develop content-rich, dynamic, personalized Web sites. In addition,
ASP.NET offers many improvements over ASP.
What Is ASP.NET?
Microsoft ASP.NET is a set of Web application development technologies that enables programmers to build
dynamic Web sites, Web applications, and XML Web services. Because ASP.NET is part of the .NET Framework, you
can develop ASP.NET Web applications in any .NET-based language.
The fundamental component of ASP.NET is the Web Form. A Web Form is the Web page that users view in a
browser. An ASP.NET Web application consists of one or more Web Forms. A Web Form is a dynamic page that can
access server resources.
For example, a traditional HTML Web page can run script on the client to perform basic tasks. However, an ASP.NET
Web Form can also run server-side code to access a database, to generate additional Web Forms, or to take
advantage of built-in security on the server.
In addition, because an ASP.NET Web Form does not rely on client-side scripting, it is not dependent on the client's
browser type or operating system. This independence enables you to develop a single Web Form that you can view
on practically any device that has Internet access and a Web browser.
You can use Visual Studio 2008 to build and execute an ASP.NET Web application. This results in a simplified
development process because you can test the application without creating an external hosting environment.
A deployed ASP.NET application runs as a process in Internet Information Services (IIS).
Question: Think of a typical production Web site with which you are familiar such as your company's intranet site.
How many different pages and other components may be required to build that Web site?
CD Content
An ASP.NET Web application contains different components. When you create a Web application, you must
understand how to implement and use all of these components.
Components
The components of an ASP.NET Web application include:
Web Forms, or .aspx pages. Web Forms provide the UI for the Web application.
Code-behind pages. Code-behind pages are associated with Web Forms and contain the server-side code for the
Web Form. You can also create a single-file ASP.NET page, which contains both the page markup and the .NET
Framework code in the same file.
Configuration files. Configuration files are XML files that define the settings for the Web application and the Web
server. Every Web application has one or more web.config configuration files. In addition, each Web server has only
one machine.config file.
Global.asax file. Global.asax files contain code for responding to application-level events that are raised by ASP.NET.
Question: You are developing and testing a new Web site. This requires constant updates to multiple Web pages.
Which form of compilation would be the best choice for this scenario: dynamic compilation or precompilation?
CD Content
ASP.NET Web pages and code files use dynamic compilation by default when a user requests a resource for the first
time. The compiled resources are then cached, which ensures that subsequent requests are performed efficiently.
In this animation, you will see how dynamic compilation in ASP.NET works to send information to a requesting
client.
First Request
When the client requests a Web page for the first time, the following set of events take place:
1. The client browser issues a GET HTTP request to the server.
2. The ASP.NET parser interprets the source code.
3. If the code was not already compiled in a dynamic-link library (DLL), ASP.NET invokes the compiler.
4. The runtime loads and executes the Microsoft intermediate language (MSIL) code.
CD Content
In the labs in this course, you will build a complete ASP.NET Web application that simulates an internal Web site for
the fictitious company, Coho Winery. This fictitious Web site provides information to employees about their benefit
options.
Details
The Benefits Web application includes the following components:
Two projects, which consist of a Web site and an XML Web service.
11 Web Forms that display the employee benefits information.
Two SQL Server databases.
Note:Throughout this course, you can develop lab solutions by using either Visual Basic or Visual C#.
The following table lists the Visual Basic and Visual C# components of the Benefits Web application.
Page or file name Description
benefitsMaster.mast Master page
er
Default.aspx Home page. Calls the BenefitsList component and lists the benefits options in a
CheckBoxList control
dental.aspx Calls the XML Web service to get a listing of dentists
doctors.aspx Lists the primary care physicians from the Doctors SQL Server database
growth.xml XML files with the prospectus information
lgcap.xml
midcap.xml
smcap.xml
header.ascx User control that is the header of each page
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 28
Why Visual Studio 2008
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 29
Available Project Templates
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 30
Integrated Development Environment
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 31
Creating an ASP.NET Web Application Project
Saturday, September 06, 2008
12:15 AM
The following table lists the additional project templates that are available in Visual Studio 2008.
Template Description
Group
Visual C++ Visual Studio 2008 includes templates for ATL projects, managed applications, managed class
Projects libraries, and managed Web services.
Other Projects Visual Studio 2008 includes templates for setup and deployment projects, database projects,
extensibility projects, and blank solutions.
Test Projects Visual Studio 2008 provides a template for a test project.
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 32
The Development Process
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 33
Web Application Types and File Structure
Saturday, September 06, 2008
12:15 AM
The choice of project template depends on your requirements and your preferred development workflow.
Question: When you create a Web application, what files does Visual Studio provide?
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 34
Web Application Files
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 35
Demonstration - Creating a Web Application Project
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 36
Student Book Content
Demonstration: Creating a Web Application Project
Question: How can you can build and browse a Web Form in one step?
CD Content
In this demonstration, the instructor will show you how to create a Web application and implement some simple
functionality.
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 37
Overview of the Microsoft .NET-Based Languages
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 38
Multiple Language Support
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 39
The Common Language Runtime
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 40
Runtime Compilation and Execution
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 41
What Are Namespaces
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 42
Comparison of the Microsoft .NET-Based Languages
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 43
Creating a Component by Using Visual Studio 2008
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 44
What Are Classes and Components
Saturday, September 06, 2008
12:15 AM
CD Content
When you use an object-oriented language (such Visual C# or Visual Basic) to develop an application, you can use
existing classes and components. For example, the .NET Framework class library consists of many classes.
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 45
Creating a Class
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 46
Accessing Components in an ASP.NET Web Form
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 47
Demonstration - Creating a Class in Visual Studio 2008
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 48
Lab - Creating Web Applications by Using Microsoft Visual Studio
2008 and Microsoft .NET-Based Languages
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 49
Student Book Content
Lab: Creating Web Applications by Using Microsoft Visual Studio
2008 and Microsoft .NET-Based Languages
Exercise 1: Creating an ASP.NET Web Site
Scenario
Coho Winery offers several benefits to its employees. In the labs for this course, you will create a Web site that
enables employees to select and set up their chosen benefits. The list of benefits that Coho Winery offers is
displayed on several pages in the Web site. Rather than code the list on every Web page that displays the offered
benefits, you have been asked to develop a component that returns the benefit names.
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 50
Exercise 1 - Creating an ASP.NET Web Site
Saturday, September 06, 2008
12:15 AM
CD Content
Review Questions
1. How would you select a .NET-based language to create a new Web application project?
Based on the developer's experience with existing languages.
2. What role does the common language runtime play in running an ASP.NET page?
The common language runtime compiles the MSIL to native code and then runs the native code on
the server.
3. What is the role of the JIT compilation?
The runtime uses a JIT compiler to compile the MSIL to native code. The runtime uses a JIT
compiler to compile the MSIL to native code. The runtime uses a JIT compiler to compile the MSIL
to native code.
4. List three languages that are currently supported by .NET.
Examples include Visual Basic, Visual C#, C++, Perl, and Cobol.
5. Why would you create a component for a Web application?
To share business logic code with other applications.
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 51
Exercise 2 - Creating a Class
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 52
Exercise 3 - Calling the Component
Saturday, September 06, 2008
12:15 AM
Module 02-Creating Web Applications by Using Microsoft Visual Studio 2008 and Microsoft .NET-Based Languages página 53
Creating Web Forms
Saturday, September 06, 2008
12:17 AM
Question: What are the key differences in the @ Page attributes for the two types of Web Forms (single file and
two file)?
CD Content
Web Forms consist of a combination of markup, code, and controls that execute on a Web server that is running
Microsoft Internet Information Services (IIS). To display a UI, Web Forms generate HTML and send it to the browser,
and the supporting code and controls that run the UI stay on the Web server. This split between client-side interface
and server-side code is a crucial difference between Web Forms and traditional Web pages. With a traditional Web
page, all of the code is processed at the browser. However, Web Forms send only the interface controls to the
browser, and the page processing remains on the server. This UI/code split increases the range of supported
browsers and the security and functionality of the Web page.
.aspx Extension
Web Forms are commonly referred to as ASP.NET pages or ASPX pages. Web Forms have an .aspx extension and are
the containers for the text and controls that you want to display on the browser.
ASP.NET (.aspx) pages and Active Server Page (ASP) pages can coexist on the same server. The file extension
determines if ASP or ASP.NET processes the page.
Web Forms often consist of two separate files: the .aspx file contains the UI for the Web Form and the .aspx.vb
or .aspx.cs file, which is called a code-behind page, contains the supporting code.
CD Content
ASP.NET server controls are components that run on the server and encapsulate UI and other related functionality.
You use server controls in ASP.NET pages and in ASP.NET code -behind classes. Server controls include buttons, text
boxes, and lists.
The following is an example of a Button server control.
<asp:Button id="Button1" runat="server" Text="Submit" />
Runat="server"•
Server controls have a runat="server" attribute, the same attribute as Web Forms. This means that the logic in
the control runs on the server and not on the user's browser. Server controls are different from HTML controls,
which run only on the client's browser.
Another feature of server controls is that the view state, the settings, and the user input of the control are
automatically saved when the page is sent back and forth between the client and the server. Traditional HTML
controls are stateless and revert to their default settings when the page returns from the server to the client.
Built-in Functionality
The functionality of a control is what happens when the user clicks a button or a list box. These processes are called
event procedures. As the Web Form programmer, you determine which event procedures to implement for each
server control.
Question: What types of server controls does your company use in its Web applications?
CD Content
HTML controls on a Web Form are not available to the server. By converting HTML controls to HTML server controls,
you can expose them as elements to your server-side code. This conversion enables you to use the controls to
trigger events that are handled on the server.
Validation Controls
Validation controls are hidden controls that validate the user's input against predetermined patterns. The following
table describes some of the commonly used validation controls.
Control Function
CompareValidator Requires that the input matches a second input or existing field.
CustomValidator Requires that the input match a condition such as prime or odd numbers.
RangeValidator Requires that the input match a specified range.
RegularExpressionV Requires that the input matches a specified format such as a U.S. telephone number or a
alidator strong password with numbers and letters.
RequiredFieldValidat Requires that the user enters some value before the control is processed.
or
ValidationSummary Collects all of the validation control error messages for centralized display.
Rich Controls
Rich controls provide a rich functionality to your Web Form by inserting complex functions into your Web Form. The
following table describes several of the presently available rich controls.
Control Function
AdRotator Displays a sequence (predefined or random) of images.
Calendar Displays a graphic calendar on which users can select dates.
Menu Displays both static and dynamic menus.
TreeView Displays hierarchical data (such as a table of contents or file directory) in a tree structure.
Wizard Provides navigation and a UI to collect related data across multiple steps.
List-Bound Controls
List-bound controls can display data from a data source. The following table describes some of the commonly used
list-bound controls.
Control Function
BulletedLi Displays a list of items in a bulleted format.
st
CheckBox Displays data as a column of check boxes.
List
Repeater Displays information from a data set by using a set of HTML elements and controls that you specify.
The Repeater control repeats the element once for each record in the data set.
DataList Displays information from a data set. Similar to the Repeater control but with more formatting and
layout options, including the ability to display information in a table. The DataList control also
allows you to specify editing behavior.
DropDown Displays data as a drop-down list.
List
GridView Displays information from many different kinds of data sources, including databases, XML files, and
business objects that expose data.
ListBox Displays data in a window.
ListView Displays data in a format that you define by using templates and styles. Implicitly supports edit,
insert, and delete operations in addition to sorting and paging functionality.
RadioButt Displays data as a column of option buttons.
onList
CD Content
5. Click OK to close the ListItem Collection Editor dialog box and save the new items.
6. Save the Default.aspx Web Form.
7. View the Default.aspx page in the browser.
8. Ensure that the items in the CheckBoxList control are correctly displayed.
9. Close the browser window.
Results:After this exercise, you have added a user control, a list-bound control, a Button control, and a Label
control to the Default.aspx page.
CD Content
Although the default method for implementing server-side code in Visual Studio 2008 is to use a code-behind page,
you may encounter pages that use inline code, especially pages that were developed for ASP.
When you double-click a control in Visual Studio 2008, Visual Studio 2008 creates an event procedure template:
In Microsoft Visual C# ®, the onclick attribute is set to the name of the event procedure.
...
• Browse the page
1. In Solution Explorer, right-click the Web Form, and then click View in Browser.
2. In the browser, click the button on the form.
3. The text of the label changes.
4. In the browser, view the source of the page to show that there is no client -side code.
There is just server-side code.
5. Close the source view of the page.
onserverclick="checkServerClick"
oncheckedchanged="checkServerChange"
runat="server"
id="Checkbox1"
Text="Certified Professional"/>
5. View the page in the browser again.
6. Enter a name in the Name box, click a value in the Profession list, select the check box,
and then click Save.
7. Both client and server event procedures run again.
• Implement a Page.IsPostBack test
1. Edit the page and set the AutoPostBack attribute to true for the check box.
2. View the page in the browser again.
CD Content
Trace.IsEnabled
There are situations when you may want to generate trace messages only when tracing is enabled for a Web page
or Web application. For these situations, the Trace object has a Boolean property named IsEnabled that enables
you to call the Write and Warn methods only when tracing is enabled. The following code illustrates this.
[Visual C#]
if (Trace.IsEnabled)
{
message = "Tracing is enabled!";
Trace.Write("myTrace", message);
}
[Visual Basic]
If Trace.IsEnabled Then
message = "Tracing is enabled!"
Trace.Write("myTrace", message)
End If
You can also use the IsEnabled property to change the state of tracing for a page dynamically. The following code
illustrates this.
Notice that the localOnly attribute is set to true (this is also the default value). This allows only local
browsers to see trace information.
8. Refresh the view of the Default.aspx page and note that trace messages are not
displayed because trace is explicitly turned off for this page.
9. View the Numbers.aspx page in the browser. This page does not have tracing turned
on, but the trace results are displayed anyway because application-level tracing is
turned on.
10.Close the browser window.
11.Add the following trace statement to the Numbers.aspx page in the click event
procedure for Button1.
[Visual C#]
Trace.Warn("Double It", "Value to double " + TextBox1.Text);
[Visual Basic]
Trace.Warn ("Double It", "Value to double " & TextBox1.Text)
12. View the Numbers.aspx page in the browser again. Enter a number into the box and
then click Double It.
The trace results, including the custom message you just added, are shown.
13. Close the browser window.
14. Change the trace tag in the web.config to turn off pageOutput.
If page output is disabled for application-level tracing, the trace messages are stored in memory. You can then view
the trace messages by using the trace viewer, which is a Web page that is included with each Web application. You
use the trace viewer by viewing the trace.axd page in a browser:
http://servername/projectname/trace.axd
For security reasons, you may want to disable the trace viewer. You can disable the trace viewer for a Web server by
editing the web.config file contained in the machine configuration folder. You can locate the machine configuration
folder in the following directory:
%systemroot%\Microsoft.NET\Framework\v2.x\Config\
In the web.config file in this folder, the reference to trace.axd (the trace viewer) is in the httpHandlers section.
This web.config file, in conjunction with the other configuration files in the folder, is inherited by all web.config files
for all web applications on the machine.
<httpHandlers>
<add verb="*" path="trace.axd"
type="System.Web.Handlers.TraceHandler"/>
</httpHandlers>
CD Content
Before you perform remote debugging, you must carry out several configuration steps.
If trace information is displayed on the page, which custom trace messages are displayed? Why?
A. Only the trace messages from the component, because trace is turned off in the page.
Results: After this exercise, you have enabled tracing in a component and disabled tracing.
CD Content
Input validation is the process of verifying that a user's input on a Web Form matches the expected data value,
range, or format. Input validation improves a user's experience with the Web site by reducing the wait time for
error messages and the likelihood of incorrect returns or Web site crashes due to problems with the user's input.
When combined with understandable and useful error messages, input validation controls can greatly improve the
usability of a Web application; this improves the customer's perception of the Web site's overall quality.
Input validation controls act to verify that the user has correctly filled in an input control, such as a TextBox
control, before the request is processed on the server. The input validation controls on a Web Form act as data
filters before the page or server logic is processed.
In ASP.NET, input validation always runs on the server side; it can also run on the client side if the client browser
supports validation. If the browser supports client-side validation, the input validation controls perform error
checking on the client before posting the data to the server. Users receive immediate feedback on whether the data
that they entered is valid. For security reasons, any input validation that is run on the client side is then repeated on
the server side.
Verifying Control Values
Input validation works by comparing user input against a predetermined input format. These predetermined input
formats can include the number of characters, the use of alphanumeric characters, the value range, a specific
character string, or a mathematical formula.
For example, a user input control that requests users to enter their telephone number can have an attached input
validation control that verifies that users have entered only numbers in a telephone number format. Entering letters
or too few numbers triggers the input validation control to display an error message and require users to re -enter
the data.
Prevents Page Processing
User input that matches the predetermined format is processed by the Web Form. User input that does not match
the predetermined format triggers an error message and stops the Web Form from processing. Further processing
of the page is blocked until the user input is corrected to meet the expected format and the page has been
resubmitted for processing.
Additional Reading: For more information about ASP.NET validation controls, see "Types of Validation for
ASP.NET Server Controls" at http://go.microsoft.com/fwlink/?LinkId=110692.
Note: For more information about control characters, see "Introduction to Regular Expressions" in the online
JScript reference.
Example of a Simple Expression
The following code example shows how you can use a RegularExpressionValidator control to check if a user
has entered a valid e-mail address.
<asp:TextBox id="emailTextBox" runat="server" />
<asp:RegularExpressionValidator id="emailRegexValidator"
runat="server"
ControlToValidate="emailTextBox"
ErrorMessage="Use the format username@organization.xxx"
ValidationExpression="\w+@\w+\.\w+"
Text="*">
</asp:RegularExpressionValidator>
The following table describes the specific pattern that the RegularExpression control checks in the previous
example.
Characters Definition
\w+ A string of at least one character.
@ An at sign (@).
\w+ A string of at least one character.
\. A period.
\w+ A string of at least one character.
When you change the Text property of the controls, you will change the text that appears in Design view. Your
page should resemble the following illustration.
Results:After this exercise, you have added RequiredFieldValidator controls for the Name, Birth Date, and
Coverage boxes on the life.aspx Web Form.
Best Practices
Help the students understand the best practices presented in this section. Ask students to consider
these best practices in the context of their own business situations.
Note: The Microsoft .NET Framework prevents files with the .ascx file extension from being viewed in a Web
browser. This security measure ensures that you cannot view the user control as a stand-alone ASP.NET page.
CD Content
Question: What properties may be required for a user control that contains a check box?
CD Content
[Visual Basic]
sumLabel.Text = (num1.Number + num2.Number).ToString()
The following example calls the Set property of the num1 and num2 user controls to display the constants 5 and 7
in the user control.
[Visual C#]
num1.Number = 5;
num2.Number = 7;
[Visual Basic]
num1.Number = 5
num2.Number = 7
Write down the HTML that is created by Visual Studio 2008 for the user control.
[Visual Basic]
Protected Sub saveButton_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles saveButton.Click
Label2.Text = nameDate1.EmpName & " born on " & _
nameDate1.EmpDOB.ToLongDateString()
End Sub
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 151
What Is ADO.NET
Saturday, September 06, 2008
12:28 AM
You can easily connect your Web application to a database by using ADO.NET.
Question: Why is ADO.NET more compatible and flexible than ADO?
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 152
The ADO.NET Object Model
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 153
DataSets and DataReaders
Saturday, September 06, 2008
12:28 AM
Question: When should you use a DataReader object instead of a DataSet object?
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 154
Accessing Data with ADO.NET
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 155
Connecting to a Database
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 156
Generating a Connection by Using Server Explorer
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 157
The DataAdapter Object Model
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 158
Generating a DataSet
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 159
Creating a Connection Programmatically
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 160
Accessing Data
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 161
Binding Data to Controls by Using the IDE
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 162
Creating a Command Object
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 163
Creating a Data Reader
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 164
Retrieving Data by Using a DataReader
Saturday, September 06, 2008
12:28 AM
[Visual Basic]
' Open connection and create command.
Dim connection As New SqlConnection _
("data source=localhost;integrated security=true;" & _
"initial catalog=myDatabase")
Dim authorsSqlCommand As New SqlCommand _
("select * from Authors", connection)
connection.Open()
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 165
// Use the returned data in the DataReader.
}
catch(Exception e)
{
// Handle the error.
}
finally
{
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 166
Creating a DataSet
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 167
Displaying a DataSet in a List-Bound Control
Saturday, September 06, 2008
12:28 AM
[Visual Basic]
' Create a connection.
Dim connection As New SqlConnection _
("data source=localhost;initial catalog=pubs;" & _
"integrated security=SSPI;persist security info=True;")
[Visual Basic]
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 168
[Visual Basic]
myDataSet.Tables("Authors")
-or-
myDataSet.Tables(0)
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 169
Handling Exceptions
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 170
Accessing Multiple Tables
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 171
Storing Data From Multiple Tables
Saturday, September 06, 2008
12:28 AM
Key Points
To fill a DataSet object with multiple DataTable objects that come from one or more data sources, you can use
multiple DataAdapter objects.
You can control the order in which updates are written to and from the database because the order of the
DataAdapter objects controls the order of implementation.
You must use a new DataAdapter object for each DataTable object in a DataSet object.
Question: How can you preserve referential integrity between related tables in a database?
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 172
Creating Relationships
Saturday, September 06, 2008
12:28 AM
[Visual Basic]
' Create the second DataTable.
ordersDataAdapter = New SqlDataAdapter _
("select CustomerID, OrderID, OrderDate, ShippedDate " & _
"from Orders", pubsConnection)
ordersDataAdapter.Fill(myDataSet, "Orders")
Note: You must use a new DataAdapter object for each DataTable object in a DataSet object, particularly if you
want to submit changes back to a data store.
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 173
Programmatically Navigating Between Tables by Using
Relationships
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 174
Lab - Accessing Data with Microsoft ADO.NET and Visual Studio
2008
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 175
Exercise 1 - Connecting to the Doctors Database
Saturday, September 06, 2008
12:28 AM
Results:After this exercise, you have implemented paging for the DataGrid control on the doctors.aspx page and
enabled the user to select a doctor from the DataGrid.
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 176
Exercise 2 - Paging and Selection in a GridView Control
Saturday, September 06, 2008
12:28 AM
[Visual Basic]
connection = New SqlConnection("data source=localhost;" & _
"integrated security=true;initial catalog=coho")
4. What is the difference between a DataSet and a DataReader object?
The DataSet object is designed to handle the actual data from a data store. The DataSet class
represents a cache of data and has database-like behavior. The DataSet object contains tables,
columns, relationships, constraints, and data. After the connection to the database is closed, the
DataSet continues to exist. The DataReader class is designed to produce a read-only, forward-only
stream that is returned from the database. The DataReader is destroyed when the connection to
the database is closed.
5. How do you create a relationship between two DataTable objects in a DataSet object?
Create a new DataRelation object from the two related DataColumns of the DataTable objects, and
then add the DataRelation object to the Relations collection of the DataSet object.
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 177
Exercise 3 - Implementing a SqlDataReader
Saturday, September 06, 2008
12:28 AM
Best Practices
Help the students understand the best practices presented in this section. Ask students to consider
these best practices in the context of their own business situations.
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 178
Exercise 4 - (If Time Permits) Viewing Doctors from All Cities
Saturday, September 06, 2008
12:28 AM
Module 08-Accessing Data with Microsoft ADO.NET and Visual Studio 2008 página 179
Overview of Stored Procedures
Saturday, September 06, 2008
12:30 AM
CD Content
To call a stored procedure, you must identify its type and then choose the method that you want to use to call the
stored procedure.
Identifying the Stored Procedure
When you call a stored procedure, the first step is to identify the type and name of the stored procedure.
You can use a DataAdapter object or a DataReader object to call all three types of stored procedures. The
method that you call to run the stored procedure varies depending on the type of stored procedure that you want
to call, as shown in the following list:
Return records stored procedures. When you call a stored procedure that returns a set of records, you can store
that set of records in a DataSet or use a DataReader to place the records directly into a list-bound control. If you
want to use a DataSet, you use a DataAdapter and the Fill method. If you want to use a DataReader, you use a
Command object and the ExecuteReader method and then bind the returned record into a list-bound control.
Return value stored procedures. When you call a stored procedure that returns a single value, call the
ExecuteScalar method of the Command object, and save the result in a variable of the appropriate data type.
CD Content
After you identify the parameters that a stored procedure supports, you must then add the parameters that you
require to the Parameters collection of the Command object.
In addition, a query expression can contain a further query clause, which is often called a subquery.
Example of a LINQ to SQL Query
In the following code example, the data source consists of the reference to the DataContext class. The query
expression contains the three clauses from, where, and select, and the expression is stored in the variable
doctorNames. Finally, the for each clause runs the query and iterates through the results.
[Visual C#]
DoctorsDataContext context1 = new DoctorsDataContext();
var doctorNames = from docs in context1.doctors
where docs.city == "Seattle"
select docs.dr_fname + " " + docs.dr_lname;
foreach (var doc in doctorNames)
{
ListBox1.Items.Add(doc);
}
[Visual Basic]
Dim context1 As New DoctorsDataContext
Dim doctorNames = From docs In context1.doctors _
Where (docs.city = "Seattle") _
Select docs.dr_fname + " " + docs.dr_lname
For Each doc In doctorNames
ListBox1.Items.Add(doc)
Next
Results: After this exercise, you have bound the citiesList list on the doctors.aspx page so that the list displays only
unique city names from the doctors database.
5. Create a new SqlCommand object named specialtiesSqlCommand that uses the doctorsConnection
object to call the getDrSpecialtystored procedure.
6. Set the specialtiesSqlCommand command type to a stored procedure.
Tools
Point out the location from which each key tool can be installed. Let students review the function and
usage of each tool on their own. Remind students that they can use this as a master list to help them
gather all the tools required to facilitate their application support work.
[Visual Basic]
Dim specialtiesSqlDataReader As SqlDataReader
doctorsConnection.Open()
specialtiesSqlDataReader = specialtiesSqlCommand.ExecuteReader()
Task 2: Bind the specialtiesListBox control to the specialtiesSqlDataReader object and make the list visible
1. In the SelectedIndexChanged event procedure, set the properties for the specialtiesListBox control as
[Visual Basic]
'myDataRelation2.Nested = True
16. On the File menu, click Save All.
17. In Solution Explorer, right-click nestedData.aspx, and then click View in Browser.
18. In the browser, analyze the XML data.
Tip: You may have to refresh the browser after the page loads to see the changes to the XML data.
In a change from the previous response, at the beginning of the file, all of the doctors are now listed sequentially,
then the specialties and drspecialtiesare nested (for every specialty, all of the drspecialtieschildren are
listed).
Note: You cannot use the two nested relationships at the same time because the same DataTable
(drspecialties) cannot be a child in two nested relations. For this reason, you have commented out the
nested property setting from the previous exercise.
19. Close the browser.
Results:After this exercise, you have experimented with nested XML data from a SQL Server database.
Best Practices
Help the students understand the best practices presented in this section. Ask students to consider
these best practices in the context of their own business situations.
CD Content
Ajax is a group of technologies that is designed to increase the responsiveness of Web pages. By using Ajax, you can
refresh parts of a page instead of the whole Web page when you must exchange data with the Web server. This
increases the speed and interactivity of the page.
Ajax works across multiple platforms and browsers and uses open standards such as JavaScript. The asynchronous
nature of Ajax means that your application can retrieve data from the server as a background task that does not
affect the current Web page display.
Ajax Technologies
AJAX makes use of several technologies, including the following:
XMLHttpRequest object, which you use to exchange data with the Web server asynchronously. This object
enables browsers to request data without a page reload and is one of the key features of Ajax.
HTML, XHTML, and cascading style sheets, which provide the markup and style information for a Web page.
XML and other data transfer formats such as JavaScript Object Notation (JSON), which you can use to transfer data
between a Web server and a client.
Document Object Model (DOM), which you use with a scripting language such as JavaScript to provide client-side
interaction with the data in a Web page.
Note: The ASP.NET 2.0 AJAX Extensions is available as a separate download for Visual Studio 2005.
Server Namespaces
The features of the ASP.NET AJAX Extensions are implemented in several namespaces. The following table describes
these namespaces.
Namespace Description
System.Web.Config Contains classes that enable you to configure the ASP.NET 2.0 AJAX Extensions
uration programmatically.
System.Web.Handle Contains HTTP Handler classes that process HTTP requests to a Web server.
rs
System.Web.Script. Contains classes that provide JSON serialization and deserialization for managed types. It
Serialization also provides extensibility features to customize serialization behavior.
System.Web.Script. Provides attributes to customize Web service support for the ASP.NET 2.0 AJAX
Services Extensions.
System.Web.UI Provides classes and interfaces that enable client-server communication and rich UIs
through the use of the ASP.NET 2.0 AJAX Extensions.
System.Web.UI.Desi Contains classes that you can use to extend design-time support for ASP.NET 2.0 AJAX
gn Extensions.
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest
(ReqHandler);
Note: There is a difference between extenders and controls. Extenders add to an existing control but do not
change the core functionality of the control. Controls provide new functionality, typically by wrapping an
existing control.
AJAX Control Toolkit Content
You download the AJAX Control Toolkit in the form of a zip file. The Toolkit contains several folders of content,
including the following:
AjaxControlToolkit folder. This folder contains the source code for the set of sample ASP.NET AJAX controls that the
Toolkit provides.
CD Content
Review Questions
1. What is the design goal of the AJAX group of technologies?
To increase the responsiveness of Web pages.
2. What features does the ScriptManager control provide?
Management of script resources and features such as partial-page rendering, localization, and
globalization.
3. How can you use the AJAX Control Toolkit to enhance your applications?
The Toolkit provides many prebuilt controls that you can add to your applications quickly. You can
also use the templates provided by the Toolkit to build your own controls and extenders.
You can also create a Polygon object and a Polyline object. These are most similar to the Path object, and in
many situations you can use the Path object to create the same shape.
There is no restriction to the number of objects that you can include in your Silverlight application. However, some
projects can become very complex, so it is often useful to utilize the Canvas object to group other objects. This
enables you to organize your application efficiently.
Additional Reading: For more information about XAML objects, see "Silverlight Overviews and How-to Topics"
at http://go.microsoft.com/fwlink/?LinkId=110700
Object properties are important because they define the actual appearance, position, and characteristics of an
object. You can declare an object (such as a Rectangle), but the object will not render until you define some
properties.
Each object type has a set of specific properties that you can use for that object, many of which are optional. You
can apply some general properties to many or all objects, particularly properties that you use to position objects.
...
Background="White">
Additional Reading: For more information about the x:Name attribute, see the "x:Name Attribute" at
Task 3: Create an event handler for when the user clicks a button
1. In the Page class, create an event handler named OnMouseDown that accepts the event type
MouseEventArgs.
2. If the user clicked a button other than the active button, perform the following:
a) Call the Begin method of the buttonName_Click storyboard where the name of the button is the button
selected.
b) Call the Begin method of the buttonName_Leave storyboard where the name of the button is the previously
selected button.
c) Check the name of the selected button, and then set the nextPage integer accordingly, for example, 1 for
Button1 and 2 for Button2.
d) Set the activeButton string to the name of the selected button.
e) Call the Begin method of the Page_Out storyboard.
To find the name of the clicked button, you can use (sender as Canvas).Name (Visual C#) or TryCast(sender,
Canvas).Name (Visual Basic).
You can use the FindName method to concatenate the name of the selected button with the string _Click or
_Leave to call the Begin method of the storyboards. For example, the following code inside an event procedure
calls the Begin method of the clicked button.
[Visual C#]
Results:After this exercise, you have added XAML code and images to display the front page of the Web site and
event handling code to display an associated picture and text when the user selects a benefit.
CD Content
XML Web services are similar to components because they represent black-box functionality that developers can
use to add features to a Web Form, Microsoft Windows ® Form, or even another XML Web service without
worrying about how the supporting service is implemented.
Application-to-Application Communication Across the Internet
XML Web services interact directly with other applications over the Internet. As a result, XML Web services do not
have user interfaces (UIs); instead, XML Web services provide standard defined interfaces called contracts that
describe the services that they provide.
An XML Web service can be used internally by a single application, or it can be used externally by many applications
that access it by using the Internet.
Language Independence
You can write a connection to an XML Web service in any Microsoft .NET Framework-based language. Because of
this flexibility, you do not have to learn a new language every time you want to use an XML Web service.
Protocol Independence
Question: What is the purpose of the proxy class that is created when you create a Web reference to an XML Web
service?
CD Content
To call an XML Web service from a Web Form, you must create a Web reference to the XML Web service in your
Web application project. The Web reference creates the proxy object that you use to communicate with the XML
Web service by using SOAP.
What Is a Proxy?
A proxy class is code that looks exactly like the class it represents; however, it does not contain any of the
application logic. Instead, the proxy class contains marshaling and transport logic. A proxy object enables a client to
access an XML Web service as if it is a local component. The proxy must be on the computer that has the Web
application.
Visual Studio 2008 automatically creates a proxy when you add a Web reference to an XML Web service.
Interaction with SOAP
Proxies and XML Web services interact by using SOAP, which is an XML protocol that you use to exchange
structured and typed information.
Additional Reading: For more information about calling an XML Web service asynchronously, see
"Communicating With XML Web Services Asynchronously" at http://go.microsoft.com/fwlink/?LinkId=110703
WebMethodNameAsync. The Async method implements the event-driven asynchronous programming model,
which was introduced in ASP.NET 2.0.
try
{
Label2.Text = getWeatherProxy.WeatherByCity(TextBox1.Text);
}
catch (Exception err)
{
Label2.Text = err.Message;
}
}
[Visual Basic]
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Button1.Click
Try
Label2.Text = getWeatherProxy.WeatherByCity(TextBox1.Text)
Catch err As Exception
Label2.Text = err.Message
End Try
End Sub
CD Content
Visual Studio 2008 provides templates and a default XML Web service method to help you start to create XML Web
services.
To create an XML Web service in Visual Studio 2008
1. Open Visual Studio 2008, and create a new ASP.NET Web Service Application project or an ASP.NET Web Service
Web site.
Visual Studio 2008 automatically creates the required folders, files, and the XML Web service page. It is
recommended that you rename the project and the XML Web service to help you to identify and maintain the
project and files.
Note: If you create a Web Service Web site, the code file that supports the logic of the Web service is placed
in the App_Code folder. For a Web Service Application project, the code file is in the application root.
2. Declare the functions for the Web service.
Visual Studio 2008 creates a default Hello World function on the XML Web service page. You can use this function
or write your own. You can write almost any kind of function as an XML Web service method from a simple local
calculation to a complex database query.
Each function must contain the [WebMethod] (Microsoft Visual C# ®) or <WebMethod()> (Microsoft Visual
Basic ®) attribute.
3. Build the ASP.NET Web Service project.
CD Content
When you create an XML Web service with Visual Studio 2008, two primary files are created that make up the XML
Web service: the .asmx file and the .asmx.cs or .asmx.vb file. The .asmx file identifies the Web page as an XML Web
service, and the .asmx.cs or .asmx.vb file contains the XML Web service logic.
[Visual Basic]
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
' To allow this Web Service to be called from script, using ASP.NET
' AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding _
(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
End Class
Results: After this exercise, you have consumed the GetDentistsByPostalCode XML Web Service method.
Question: What are the differences between server-side and client-side state management?
Question: What must you modify in the Web.config file to configure the session state?
Results:After this exercise, you have used cookies to store all of a user's benefits selections and when a user
returns to the Default.aspx page, the page lists the selected benefits for the user.
CD Content
Review Questions
1. How do you set up a Web application to use cookieless sessions?
Create a <sessionState> section in the Web.config file and set the cookieless attribute to true.
<sessionState cookieless="true"/>
2. What are the three categories of events that are handled in the Global.asax file?
Events that are fired when a page is requested, events that are fired when the requested page is
sent, and conditional application events.
3. Why must you initialize application variables?
You must initialize application variables because they can produce a null reference exception.
4. Where can you initialize application variables?
It is advisable to create and initialize application variables in the Application_Start event of the
Global.asax file.
5. Can there be more than one Global.asax file for a single Web application?
No, but you can also have a Global.asax file if the application contains ASP pages.
Best Practices
Help the students understand the best practices presented in this section. Ask students to consider
these best practices in the context of their own business situations.
Tools
Point out the location from which each key tool can be installed. Let students review the function and
usage of each tool on their own. Remind students that they can use this as a master list to help them
gather all the tools required to facilitate their application support work.
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 298
What Is the Cache Object
Saturday, September 06, 2008
12:42 AM
Question: What are some possible uses for the Cache object in your own applications?
CD Content
An issue that you will encounter when you build high-performance Web applications is the requirement to avoid
duplication. A Cache object enables you to store items in memory the first time that they are requested and then
use the cached copy for later requests. By using the cached copy, you do not have to recreate information that
satisfied a previous request, particularly information that demands significant processor time on the server every
time that it is created.
In addition to caching individual items such as computational results in the Cache object, ASP.NET offers an output
cache that you can use to store Web pages and user controls. The Cache object and the output cache are distinct
objects with unique roles and properties.
Storing Information
ASP.NET provides a full-featured cache engine that you use to store and retrieve information. The Cache object
has no information about the content of the items it contains. The Cache object merely holds a reference to those
objects and provides a process to track their dependencies and set expiration policies.
The Cache object also provides a method to pass values between pages in the same Web application. The cache
methods implement automatic locking; therefore, it is safe for the application to access values concurrently from
more than one page.
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 299
Advantages of the Cache Object
Saturday, September 06, 2008
12:42 AM
[Visual Basic]
Cache("mykey") = myValue
[Visual Basic]
myValue = Cache("myKey")
Additional Reading: For more information on caching, see "Caching Application Data",
http://go.microsoft.com/fwlink/?LinkId=110706
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 300
How to Use the Cache Object
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 301
Removing Items from the Cache Object
Saturday, September 06, 2008
12:42 AM
[Visual Basic]
Cache.Insert("MyBook.CurrentBook", CurrentBook, new CacheDependency _
(Server.MapPath("Books.xml")), DateTime.Now.AddMinutes(5), _
TimeSpan.FromSeconds(30), CacheItemPriority.High, onRemove)
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 302
ASP.NET Output Caching
Saturday, September 06, 2008
12:42 AM
[Visual Basic]
Cache.Insert("myKey", myValue, Nothing, _
Nothing, TimeSpan.FromSeconds(20))
Dependencies
There are times when you want to remove an object from the Cache object because a related item such as a file
has changed. ASP.NET enables you to define the validity of a cached item based on file dependencies or another
cached item. Dependencies based on external files and directories are referred to as file dependencies;
dependencies based on another cached item are referred to as key dependencies. If a dependency changes,
ASP.NET invalidates the cached item and removes it from the Cache object.
The following code example removes myValue from the Cache object when the myDoc.xml file changes.
[Visual C#]
Cache.Insert("myKey", myValue, new CacheDependency(Server.MapPath("myDoc.xml")));
[Visual Basic]
Cache.Insert("myKey", myValue, _
new CacheDependency(Server.MapPath("myDoc.xml")))
[Visual Basic]
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 303
Multimedia - Output Caching
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 304
Output Cache Types
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 305
Implementing the Page Output Cache
Saturday, September 06, 2008
12:42 AM
CD Content
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 306
Implementing Control Caching
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 307
Configuring an ASP.NET Web Application
Saturday, September 06, 2008
12:42 AM
[Visual Basic]
<PartialCaching(25)> _
Partial Class myControl
Inherits UserControl
...
End Class
Post-Cache Substitution
Post-cache substitution enables you to cache a Web page but enable sections of the page to remain dynamic. You
specify that areas of a page cannot be placed in the cache by using the Substitution or AdRotator controls.
These areas of the page are then created dynamically at each page request and combined with the cached page
output.
Additional Reading: For more information about post-cache substitution, see "Dynamically Updating Portions
of a Cached Page" at http://go.microsoft.com/fwlink/?LinkId=110710
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 308
Overview of Configuration Files
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 309
Configuring a Web Server by Using Machine.config
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 310
Configuring an Application by Using Web.config
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 311
Configuration Inheritance
Saturday, September 06, 2008
12:42 AM
Note: For more information about security in the web.config file, see Module 16, "Securing a Microsoft
ASP.NET Web Application."•
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 312
Demonstration - Configuration Inheritance
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 313
Web Site Administration Tool
Saturday, September 06, 2008
12:42 AM
Question: In what situations may you have to take a Web application offline?
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 314
Retrieving Data from Web.config
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 315
Deploying an ASP.NET Web Application
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 316
Web Application Deployment
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 317
Deploying a Web Application by Using the Publish Web Site Utility
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 318
Sharing Assemblies in the Global Assembly Cache
Saturday, September 06, 2008
12:42 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 319
Updating Your Web Application
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 320
Lab - Configuring, Optimizing, and Deploying a Microsoft ASP.NET
Web Application
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 321
Exercise 1 - Caching a DataSet by Using the Cache Object
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 322
Exercise 2 - Reducing Response Times by Using the Page Output
Cache
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 323
Exercise 3 - Partial-Page Caching
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 324
Exercise 4 - Deploying Your Site
Saturday, September 06, 2008
12:43 AM
Module 15-Configuring, Optimizing, and Deploying a Microsoft ASP.NET Web Application página 325
Web Application Security Overview
Saturday, September 06, 2008
12:44 AM
Question: Does authentication occur before or after authorization or do they both occur at the same time?
Security Note: Anonymous access is enabled so that you can have both secure and non-secure pages in the
same Web application. For this exercise, Basic authentication has been enabled without the use of Secure
Sockets Layer (SSL); therefore, passwords are sent by using clear text. In a real-world scenario, to be secure,
you must obtain a server certificate and implement SSL when you use Basic authentication.
Task 9: Test Windows-based authentication for two pages
2. In a new browser, browse to http://localhost/Benefits/default.aspx.
Best Practices
Help the students understand the best practices presented in this section. Ask students to consider
these best practices in the context of their own business situations.
Tools
Point out the location from which each key tool can be installed. Let students review the function and
usage of each tool on their own. Remind students that they can use this as a master list to help them
gather all the tools required to facilitate their application support work.