Upload
eshamu
View
222
Download
0
Embed Size (px)
Citation preview
7/31/2019 c Session 14
1/25
Performing ASP.NET
Administrative Tasks
7/31/2019 c Session 14
2/25
Configuration as ASP.NET Application
Debugging ASP.NET Application
Identifying ASP.NET Application Debugging Methods
Handling Internet Related Exceptions
Objective
7/31/2019 c Session 14
3/25
ASP.NET Configuration system is used to describe the
properties and behaviors of various aspects ofASP.NET applications
ASP.NET uses XML-based configuration system that ismore accessible and easier to use.
You can configure features, such as ConnectionStrings, Authentication Modes, Caching, Debug andTracing, Custom Errors and many more.
ASP.NET Configuration System
7/31/2019 c Session 14
4/25
ASP.NET configuration data is stored in two primary
XML-based files. These files allow you to easily edit configuration data
at any moment even after the application is deployedon server.
Configuration Files
7/31/2019 c Session 14
5/25
Machine.config: Server or machine-wide
configuration file Web.config: Application configuration files which deal
with a single application
Different types of Configuration files
7/31/2019 c Session 14
6/25
Every ASP.NET server installation includes a
configuration file named machine.config, and this fileis installed as a part of .NET Framework installation.
You can find machine.config inC:\\Microsoft.NET\Framework\\Config\
Server Configuration file (Machine.config)
7/31/2019 c Session 14
7/25
Each and Every ASP.NET application has its own copy
of configuration settings stored in a file calledWeb.config.
If the web application spans multiple folders, eachsub folder has its own Web.config file that inherits or
overrides the parent's file settings.
Application Configuration file (Web.config)
7/31/2019 c Session 14
8/25
Common section groups/settings present in the
configuration files. Connection Strings
Session State
Custom Errors
Authentication
Common Configuration Settings (Machine.config &Web.config)
7/31/2019 c Session 14
9/25
ASP.NET 2.0 introduces a new section called
that stores all kinds ofconnection-string information.
Connection Strings
7/31/2019 c Session 14
10/25
Session information using the element
It can be used to persist state in any permanent store like XML ordatabases
sessionStatemode ="StateServer"cookieless ="false"timeout ="20"
stateConnectionString="tcpip=aras02:42424"stateNetworkTimeout="60"sqlConnectionString =""/>
Session State
7/31/2019 c Session 14
11/25
When the ASP.NET application fails, the ASP.NET
page can show the default error page with the sourcecode and line number.
We can prevent this kind of error messages byconfiguring element which allows for
defining custom error messages in an ASP.NETapplication.
Custom Errors
7/31/2019 c Session 14
12/25
Every web application must store some application-
specific information for its runtime use. The"appSettings" section provides a way to definecustom application settings for an ASP.NETapplication.
Custom Application Specific
settings
7/31/2019 c Session 14
13/25
Debugging is the process of finding and fixing errors
in your application Two types of errors:
Compile time errors: these are largely syntactic errorswhich will be captured by the compiler. Note, that use
of Option Explicit and Option Strict can reduce thelikelihood of runtime errors via compile timeidentification of likely issues. See my article on ErrorHandling in ASP.NET for more information.
Runtime errors: these are bugs programs that compile
successfully but do not behave as expected.
Debugging An Application
7/31/2019 c Session 14
14/25
Debug mode may be set explicitly within the
web.config file
Debug Mode
7/31/2019 c Session 14
15/25
Stepping is the step-by-step execution of a program
The steps of the stepping process are definable by the developer. Thedebug menu of VS.NET provides three options for step execution:
Step Into: executes the code in step mode if a method call isencountered the program execution steps into the code in step mode.
Step Over: will not execute the next method call in step mode,continuing to the next statement after the method call.
Step Out: if already in a method call will continue through the rest ofthe method without stepping, returning to step mode when controlreturns to the calling statement.
Setting Breakpoints and Stepping Through ProgramExecution
7/31/2019 c Session 14
16/25
Watch
The Watch window allows you to add 'watches' to particularly variables and expression for continuousmonitoring. Thus when you set up a watch whenever you return to the IDE while debugging you will see
the current value of the variable or expression defined by the watch.
Autos
The autos window (automatically) displays the variables in the current statement and the previous
statement.
Locals
Displays the variables local to the current context, i.e. the current method under execution
Me
The Me window allows you to examine members associated with the current object typically a web
form for an ASP.NET application, but not necessarily. It also allows you to change these values.
Immediate
The immediate window allows (immediate) access to the values of variables and expressions while
debugging, at the breakpoint.
Call Stack
The Call Stack window shows you the method call stack thus providing information about the path
taken by the code to reach its current point of execution
.NET debugging tools
7/31/2019 c Session 14
17/25
Turning debugging on and off at the page level is easy
enough when you're making changes to only a fewpages
You can activate Debug mode at the application levelby setting the Debug attribute of the compilation
section in Web.config
Enabling Debugging at the Application Level
7/31/2019 c Session 14
18/25
The .NET framework provides a Debug object that
you can use to assist with debugging your application The Debug object is a member of
System.Diagnostics.Debug.
Using the Debug Object
private void Page_Load(Object Sender , EventArgs e)
{
Debug.Write("Application initializing. Poot.");
}
7/31/2019 c Session 14
19/25
A performance monitor is a feature of the Windows
NT/2000 operating system used to determineoperating system resource consumption in real-time
ASP.NET have their own set of performance monitorsthat broadcast meaningful information to the
operating system about resources consumed bythese services
.NET application can be equipped with performancemonitors that you create yourself, called custom
performance monitors
Creating Custom PerformanceMonitors
7/31/2019 c Session 14
20/25
Windows event log is a central, system-managed
place where any application, service, or device can loginformation.
ASP.NET applications, can access the event log. Yourapplications will write information to the application
log The .NET framework provides a class for handling the
event log. This is the EventLog class, found inSystem.Diagnostics.
Windows Event Log
7/31/2019 c Session 14
21/25
void Button1_Click(Object Sender, EventArgs e)
{ if(!EventLog.SourceExists("MyApp")) {EventLog.CreateEventSource("MyApp","Application"); } EventLog.WriteEntry("MyApp","This is just a test.", EventLogEntryType.Information);
}
Event to the Windows Event Log
7/31/2019 c Session 14
22/25
Tracing is a way to monitor the execution of your
ASP.NET application. You can record exception details and program flow in
a way that doesn't affect the program's output.
Tracing
7/31/2019 c Session 14
23/25
ASP.NET tracing can be enabled on a page-by-page
basis by adding "Trace=true" to the Page directive inany ASP.NET page
ASP.NET tracing can be enabled on a page-by-page basisby adding "Trace=true" to the Page directive in any
ASP.NET page you can add the TraceMode attribute that sets
SortByCategory or the default, SortByTime
Page level Tracing
7/31/2019 c Session 14
24/25
You can enable tracing for the entire application by adding tracing
settings in web.config.
In Above example, pageOutput="false" and requestLimit="20" are used, so
Application Tracing
7/31/2019 c Session 14
25/25
Tracing can be viewed for multiple page requests at the application level
by requesting a special page called trace.axd
protected void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Trace.Write("This is Page_Load method!");
Viewing Trace Data