SlideShare a Scribd company logo
1 of 34
ASP.NET Application

Anatomy   of ASP.NET
application
 global.asax Application file
 ASP.NET Configuration
 .NET Components,
Extending the HTTP Pipeline
In traditional desktop programming,
an application is an executable file
with related support files. (EXE & DLL
Files) and other resources such as
databases and configuration files.



ASP.NET application is a combination
of files, pages, handlers, modules, and
executable code that can be invoked
from a virtual directory.
Anatomy of an ASP.NET
Application
   Unlike a  Windows application, the end user
      never runs an ASP.NET application directly.

     The web server has no concept of separate
      applications - it simply passes the request to the
      ASP.NET worker process.

      Web pages that are hosted in the same virtual
      directory (or one of its subdirectories) execute in
      the same application domain.

     A virtual directory is simply a directory that’s
      exposed through a web server.
The Application Domain
   An application domain is a boundary enforced by the CLR
    that ensures that one application can’t influence (or see the
    in-memory data) of another.

   The following characteristics are a direct result of the
    application domain mode.

     All the web pages in a single web application share the
     same in-memory resources, such as global application
     data, per-user session data, and cached data.

     All the web pages in a single web application share the
     same core configuration settings.

     All web applications raise global application events at
     various stages.
The Application Domain cont..
  ASP.NET applications can include all   of the following
   ingredients.

    Web pages (.aspx files)

    Web services (.asmx files)

    Code-behind files

    A configuration file (web.config)

    global.asax

    Other components (components developed or
     third-party components with useful functionality)
Application Lifetime
  ASP.NET     uses a lazy initialization technique
     for creating application domains.
     Means that the application domain for a web
     application is created the first time a request is
     received for a page in that application.
     An application domain can shut down for a
     variety of reasons, including if the web server
     itself shuts down.
    ASP.NET automatically recycles application
     domains when you change the application.
Application Lifetime cont..
ASP.NET application may   be periodically
 recycled when certain thresholds are
 reached.

 This model is designed to keep an
 application healthy

 And to detect characteristics that could
 indicate a problem has developed or
 performance of the application has
 degraded.
Application Updates
 Can update     your web application without needing
    to restart the web server and without worrying
    about harming existing clients.
   Transits to a new application domain when
    web.config configuration file is modified.
    ASP.NET doesn’t actually use the ASP.NET files in
    the virtual directory.
    Instead, it uses another technique, called
    shadow copy, (uses files in
    c:WindowsMicrosoft.NETv2.0.50727Temporar
    y ASP.NET Files)
   ASP.NET’s ability to detect when you change the
    original files (relies Windows operating system)
Application Directory Structure

  Every web application should have   a
   well-planned directory structure.
   Independently from the directory
   structure designed, ASP.NET defines a
   few directories with special meanings.
Application Directory Structure
cont..
The global.asax Application File
     The global.asax file allows you to write event handlers
      that react to global events.
     Users cann’t request the global.asax file directly.
     Instead, the global.asax file executes its code
      automatically in response to certain application events.
     global.asax doesn’t contain any HTML or ASP.NET tags.
     It contains methods with specific, predefined names.
      Every global.asax file defines the methods for a single
      class—the application class (class derives from
      HttpApplication)
     The global.asax file is optional, but a web application can
      have only one global.asax file.
The global.asax Application File
cont..
      global.asax   must reside in the root directory of
         the application, not in a subdirectory.

         An application event handler is just to use the
         recognized method name (as opposed to web
         controls events).

        ASP.NET automatically calls methods in
         global.asax when the application event occurs.

      ASP.NET     creates a pool of application objects
         when your application domain is first loaded
         and uses one to serve each request.
Application Events
   Developer can handle two types of
    events in the global.asax file:
   Events that always occur for every
    request. These include request-related
    and response related events.
   Events that occur only under certain
    conditions.
Application Events cont..
Application Events cont..
Application Events cont..
Application Events cont..
 Avoid use   of use the Application_Error()
    method to control the appearance of a web
    page. (without coding painstaking conditional
    logic)

    Instead, you would probably configure
    custom error pages using the web.config file.

    Application_Error() might be extremely
    useful for logging an error for future
    reference or even send an e-mail about error
    to a system administrator
ASP.NET Configuration
 Configuration in ASP.NETis managed with
    XML configuration files.

   The ASP.NET configuration files have several
    advantages over traditional ASP configuration
     They are never locked.

     They are easily accessed and replicated.

     They are easy to edit and understand

     No need of configuration tool
The machine.config File
   machine.config that resides in the directory
    c:Windows
    Microsoft.NETFrameworkv2.0.50727Config.
    defines supported configuration file sections,
    configures the ASP.NET worker process, and registers
    providers that can be used for advanced features such as
    profiles, membership, and role-based security
   <processModel>
      This section allows you to configure how the
    ASP.NET worker process recycles application domains,
   <machineKey>
   This section allows you to set the server-specific key
    used for encrypting data and creating digital signatures.
The web.config File
 Every web application  inherits the settings
    from the machine.config file and the root
    web.config file

   For example, you might want to set a specific
    method for authentication, a type of
    debugging, a default language, or custom
    error pages.

    web.config file in a web application can’t
    override all the settings in the machine.config
    file
The web.config File cont..
 Basic skeletal   structure of the web.config file
  <?xml version="1.0"?>
  <configuration>
        <appSettings />
        <connectionStrings />
        <system.web>
         <!-- ASP.NET configuration sections go here.
  -->
        </system.web>
  </configuration>
Configuration Inheritance
   The default machine.config settings are applied first.
   The web.config settings from the computer root are
    applied next. This web.config file is in
   the same Config directory as the machine.config file.
    If there is a web.config file in the application root A,
    these settings are applied next.
    If there is a web.config file in the subdirectory B, these
    settings are applied next.
    If there is a web.config file in the subdirectory C, these
    settings are applied last.
Configuration Inheritance cont..
The web.config file cont..
     <customErrors>
      allows you to configure the behavior of
      your application in response to various
      HTTP
      errors.

  For Example
  <customErrors
   defaultRedirect="standarderror.aspx"
   mode="RemoteOnly">
  <error statusCode="404"
   redirect="filenotfound.htm"/>
  </customErrors>
The web.config file cont..
   The following is a list of the modes
    supported for the mode attribute:
   On: Indicates that custom errors are
    enabled. If no defaultRedirect attribute is
    supplied, users will see a generic error.
   Off: Custom errors are disabled. This
    allows full error details to be displayed.
   RemoteOnly: Custom errors are shown
    only to remote clients while full detailed
    errors are displayed to local clients.
The web.config file
(<system.web> Settings)
The web.config file
(<system.web> Settings)
The web.config file
(<system.web> Settings)
   <configuration>
   <connectionStrings>
   <add name="NorthwindConnection”
    connectionString=
   "Data Source=localhost;Integrated
    Security=SSPI;Initial
    Catalog=Northwind;"
   providerName="System.Data.SqlClient
    " />
   </connectionStrings>
   <system.web>...</system.web>
   </configuration>
Reading and Writing Configuration Sections Programmatically
   ASP.NET provides the
    WebConfigurationManager class in the
    System.Web.Configuration namespace,
    which allows you to extract information
    from a configuration file at runtime.
Reading and Writing Configuration Sections Programmatically

    Forexample, if you’re retrieving information from the
     <authentication> section, you’ll receive an
     AuthenticationSection object, as shown here:

   // Get the configuration for the current web application.

   Configuration config =
   WebConfigurationManager.OpenWebConfiguration("/");

   // Search for the <authentication> element inside the
     <system.web> element.

   AuthenticationSection authSection =
   (AuthenticationSection)config.GetSection(@"system.web/
     authentication");
The Website
Administration Tool (WAT)
 Letsyou configure various parts of the
 web.config file using a web-page
 interface.
 To run the WAT to configure the current
 web application in Visual Studio, select
 Website ➤ ASP.NET Configuration (or
 Project ➤ ASP.NET Configuration if
 you’re using projectbased development).
 Can use the WAT to automate the
 web.config changes
Extending the HTTP
Pipeline
 The pipeline of   application events isn’t
    limited to requests for .aspx web forms.
    One example is if you want to create a
    web resource that dynamically renders a
    custom graphic.
    In this situation, you simply need to
    receive a request, check the URL
    parameters, and then return raw image
    data as a JPEG or GIF file.
Ch 04 asp.net application

More Related Content

What's hot

RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.netBhumivaghasiya
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net frameworkThen Murugeshwari
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETRajkumarsoy
 
State management
State managementState management
State managementteach4uin
 
Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing filesMukesh Tekwani
 
dot net technology
dot net technologydot net technology
dot net technologyImran Khan
 
Properties and indexers in C#
Properties and indexers in C#Properties and indexers in C#
Properties and indexers in C#Hemant Chetwani
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web ArchitectureChamnap Chhorn
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework OverviewDoncho Minkov
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life CycleAbhishek Sur
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1Kumar S
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types pptkamal kotecha
 

What's hot (20)

JDBC
JDBCJDBC
JDBC
 
RichControl in Asp.net
RichControl in Asp.netRichControl in Asp.net
RichControl in Asp.net
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Ch 7 data binding
Ch 7 data bindingCh 7 data binding
Ch 7 data binding
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
State management
State managementState management
State management
 
Javascript tutorial
Javascript tutorialJavascript tutorial
Javascript tutorial
 
C#.NET
C#.NETC#.NET
C#.NET
 
Python reading and writing files
Python reading and writing filesPython reading and writing files
Python reading and writing files
 
dot net technology
dot net technologydot net technology
dot net technology
 
Properties and indexers in C#
Properties and indexers in C#Properties and indexers in C#
Properties and indexers in C#
 
Delegates and events in C#
Delegates and events in C#Delegates and events in C#
Delegates and events in C#
 
Introduction to Web Architecture
Introduction to Web ArchitectureIntroduction to Web Architecture
Introduction to Web Architecture
 
.NET Framework Overview
.NET Framework Overview.NET Framework Overview
.NET Framework Overview
 
ASP.NET Page Life Cycle
ASP.NET Page Life CycleASP.NET Page Life Cycle
ASP.NET Page Life Cycle
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1ASP.NET Tutorial - Presentation 1
ASP.NET Tutorial - Presentation 1
 
Jdbc architecture and driver types ppt
Jdbc architecture and driver types pptJdbc architecture and driver types ppt
Jdbc architecture and driver types ppt
 

Viewers also liked

Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web ApplicationRishi Kothari
 
Harish Understanding Aspnet
Harish Understanding AspnetHarish Understanding Aspnet
Harish Understanding Aspnetrsnarayanan
 
Skillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise Group
 
Beginning asp.net application Development with visual studio 2013
Beginning asp.net application Development with visual studio 2013Beginning asp.net application Development with visual studio 2013
Beginning asp.net application Development with visual studio 2013Abhijit B.
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationabhishek singh
 
Directives in asp.net
Directives in asp.netDirectives in asp.net
Directives in asp.netSireesh K
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05Niit Care
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.netshan km
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showSubhas Malik
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NETPeter Gfader
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State managementShivanand Arur
 
Be project ppt asp.net
Be project ppt asp.netBe project ppt asp.net
Be project ppt asp.netSanket Jagare
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web applicationRahul Bansal
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API💻 Spencer Schneidenbach
 

Viewers also liked (19)

Asp.net
 Asp.net Asp.net
Asp.net
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
Harish Understanding Aspnet
Harish Understanding AspnetHarish Understanding Aspnet
Harish Understanding Aspnet
 
Skillwise - Advanced web application development
Skillwise - Advanced web application developmentSkillwise - Advanced web application development
Skillwise - Advanced web application development
 
Beginning asp.net application Development with visual studio 2013
Beginning asp.net application Development with visual studio 2013Beginning asp.net application Development with visual studio 2013
Beginning asp.net application Development with visual studio 2013
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentation
 
Directives in asp.net
Directives in asp.netDirectives in asp.net
Directives in asp.net
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Asp dot net final (2)
Asp dot net   final (2)Asp dot net   final (2)
Asp dot net final (2)
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide showThe complete ASP.NET (IIS) Tutorial with code example in power point slide show
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
ASP.NET State management
ASP.NET State managementASP.NET State management
ASP.NET State management
 
Be project ppt asp.net
Be project ppt asp.netBe project ppt asp.net
Be project ppt asp.net
 
IPSec and VPN
IPSec and VPNIPSec and VPN
IPSec and VPN
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Developing an aspnet web application
Developing an aspnet web applicationDeveloping an aspnet web application
Developing an aspnet web application
 
RESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web APIRESTful API Design Best Practices Using ASP.NET Web API
RESTful API Design Best Practices Using ASP.NET Web API
 

Similar to Ch 04 asp.net application (20)

Chapter 5
Chapter 5Chapter 5
Chapter 5
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
ASP.NET Unit-2.pdf
ASP.NET Unit-2.pdfASP.NET Unit-2.pdf
ASP.NET Unit-2.pdf
 
Asp.net file types
Asp.net file typesAsp.net file types
Asp.net file types
 
Asp.net
Asp.netAsp.net
Asp.net
 
Web tech
Web techWeb tech
Web tech
 
Web techh
Web techhWeb techh
Web techh
 
Web tech
Web techWeb tech
Web tech
 
Web tech
Web techWeb tech
Web tech
 
Programming web application
Programming web applicationProgramming web application
Programming web application
 
Asp.net
Asp.netAsp.net
Asp.net
 
Asp.netrole
Asp.netroleAsp.netrole
Asp.netrole
 
ASP.Net Presentation Part1
ASP.Net Presentation Part1ASP.Net Presentation Part1
ASP.Net Presentation Part1
 
Road Show Asp Net
Road Show Asp NetRoad Show Asp Net
Road Show Asp Net
 
Introduction to asp.net
Introduction to asp.netIntroduction to asp.net
Introduction to asp.net
 
Asp .net web form fundamentals
Asp .net web form fundamentalsAsp .net web form fundamentals
Asp .net web form fundamentals
 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
 
15th june
15th june15th june
15th june
 
05 asp.net session07
05 asp.net session0705 asp.net session07
05 asp.net session07
 
R12 d49656 gc10-apps dba 16
R12 d49656 gc10-apps dba 16R12 d49656 gc10-apps dba 16
R12 d49656 gc10-apps dba 16
 

Ch 04 asp.net application

  • 1. ASP.NET Application Anatomy of ASP.NET application  global.asax Application file  ASP.NET Configuration  .NET Components, Extending the HTTP Pipeline
  • 2. In traditional desktop programming, an application is an executable file with related support files. (EXE & DLL Files) and other resources such as databases and configuration files. ASP.NET application is a combination of files, pages, handlers, modules, and executable code that can be invoked from a virtual directory.
  • 3. Anatomy of an ASP.NET Application  Unlike a Windows application, the end user never runs an ASP.NET application directly.  The web server has no concept of separate applications - it simply passes the request to the ASP.NET worker process.  Web pages that are hosted in the same virtual directory (or one of its subdirectories) execute in the same application domain.  A virtual directory is simply a directory that’s exposed through a web server.
  • 4. The Application Domain  An application domain is a boundary enforced by the CLR that ensures that one application can’t influence (or see the in-memory data) of another.  The following characteristics are a direct result of the application domain mode.  All the web pages in a single web application share the same in-memory resources, such as global application data, per-user session data, and cached data.  All the web pages in a single web application share the same core configuration settings.  All web applications raise global application events at various stages.
  • 5. The Application Domain cont..  ASP.NET applications can include all of the following ingredients.  Web pages (.aspx files)  Web services (.asmx files)  Code-behind files  A configuration file (web.config)  global.asax  Other components (components developed or third-party components with useful functionality)
  • 6. Application Lifetime  ASP.NET uses a lazy initialization technique for creating application domains.  Means that the application domain for a web application is created the first time a request is received for a page in that application.  An application domain can shut down for a variety of reasons, including if the web server itself shuts down.  ASP.NET automatically recycles application domains when you change the application.
  • 7. Application Lifetime cont.. ASP.NET application may be periodically recycled when certain thresholds are reached.  This model is designed to keep an application healthy  And to detect characteristics that could indicate a problem has developed or performance of the application has degraded.
  • 8. Application Updates  Can update your web application without needing to restart the web server and without worrying about harming existing clients.  Transits to a new application domain when web.config configuration file is modified.  ASP.NET doesn’t actually use the ASP.NET files in the virtual directory.  Instead, it uses another technique, called shadow copy, (uses files in c:WindowsMicrosoft.NETv2.0.50727Temporar y ASP.NET Files)  ASP.NET’s ability to detect when you change the original files (relies Windows operating system)
  • 9. Application Directory Structure Every web application should have a well-planned directory structure.  Independently from the directory structure designed, ASP.NET defines a few directories with special meanings.
  • 11. The global.asax Application File  The global.asax file allows you to write event handlers that react to global events.  Users cann’t request the global.asax file directly.  Instead, the global.asax file executes its code automatically in response to certain application events.  global.asax doesn’t contain any HTML or ASP.NET tags.  It contains methods with specific, predefined names.  Every global.asax file defines the methods for a single class—the application class (class derives from HttpApplication)  The global.asax file is optional, but a web application can have only one global.asax file.
  • 12. The global.asax Application File cont..  global.asax must reside in the root directory of the application, not in a subdirectory.  An application event handler is just to use the recognized method name (as opposed to web controls events).  ASP.NET automatically calls methods in global.asax when the application event occurs.  ASP.NET creates a pool of application objects when your application domain is first loaded and uses one to serve each request.
  • 13. Application Events  Developer can handle two types of events in the global.asax file:  Events that always occur for every request. These include request-related and response related events.  Events that occur only under certain conditions.
  • 17. Application Events cont..  Avoid use of use the Application_Error() method to control the appearance of a web page. (without coding painstaking conditional logic)  Instead, you would probably configure custom error pages using the web.config file.  Application_Error() might be extremely useful for logging an error for future reference or even send an e-mail about error to a system administrator
  • 18. ASP.NET Configuration  Configuration in ASP.NETis managed with XML configuration files.  The ASP.NET configuration files have several advantages over traditional ASP configuration  They are never locked.  They are easily accessed and replicated.  They are easy to edit and understand  No need of configuration tool
  • 19. The machine.config File  machine.config that resides in the directory c:Windows Microsoft.NETFrameworkv2.0.50727Config.  defines supported configuration file sections, configures the ASP.NET worker process, and registers providers that can be used for advanced features such as profiles, membership, and role-based security  <processModel>  This section allows you to configure how the ASP.NET worker process recycles application domains,  <machineKey>  This section allows you to set the server-specific key used for encrypting data and creating digital signatures.
  • 20. The web.config File  Every web application inherits the settings from the machine.config file and the root web.config file  For example, you might want to set a specific method for authentication, a type of debugging, a default language, or custom error pages.  web.config file in a web application can’t override all the settings in the machine.config file
  • 21. The web.config File cont..  Basic skeletal structure of the web.config file <?xml version="1.0"?> <configuration> <appSettings /> <connectionStrings /> <system.web> <!-- ASP.NET configuration sections go here. --> </system.web> </configuration>
  • 22. Configuration Inheritance  The default machine.config settings are applied first.  The web.config settings from the computer root are applied next. This web.config file is in  the same Config directory as the machine.config file.  If there is a web.config file in the application root A, these settings are applied next.  If there is a web.config file in the subdirectory B, these settings are applied next.  If there is a web.config file in the subdirectory C, these settings are applied last.
  • 24. The web.config file cont..  <customErrors> allows you to configure the behavior of your application in response to various HTTP errors. For Example <customErrors defaultRedirect="standarderror.aspx" mode="RemoteOnly"> <error statusCode="404" redirect="filenotfound.htm"/> </customErrors>
  • 25. The web.config file cont..  The following is a list of the modes supported for the mode attribute:  On: Indicates that custom errors are enabled. If no defaultRedirect attribute is supplied, users will see a generic error.  Off: Custom errors are disabled. This allows full error details to be displayed.  RemoteOnly: Custom errors are shown only to remote clients while full detailed errors are displayed to local clients.
  • 28. The web.config file (<system.web> Settings)  <configuration>  <connectionStrings>  <add name="NorthwindConnection” connectionString=  "Data Source=localhost;Integrated Security=SSPI;Initial Catalog=Northwind;"  providerName="System.Data.SqlClient " />  </connectionStrings>  <system.web>...</system.web>  </configuration>
  • 29. Reading and Writing Configuration Sections Programmatically
  • 30. ASP.NET provides the WebConfigurationManager class in the System.Web.Configuration namespace, which allows you to extract information from a configuration file at runtime.
  • 31. Reading and Writing Configuration Sections Programmatically  Forexample, if you’re retrieving information from the <authentication> section, you’ll receive an AuthenticationSection object, as shown here: // Get the configuration for the current web application. Configuration config = WebConfigurationManager.OpenWebConfiguration("/"); // Search for the <authentication> element inside the <system.web> element. AuthenticationSection authSection = (AuthenticationSection)config.GetSection(@"system.web/ authentication");
  • 32. The Website Administration Tool (WAT)  Letsyou configure various parts of the web.config file using a web-page interface.  To run the WAT to configure the current web application in Visual Studio, select Website ➤ ASP.NET Configuration (or Project ➤ ASP.NET Configuration if you’re using projectbased development).  Can use the WAT to automate the web.config changes
  • 33. Extending the HTTP Pipeline  The pipeline of application events isn’t limited to requests for .aspx web forms.  One example is if you want to create a web resource that dynamically renders a custom graphic.  In this situation, you simply need to receive a request, check the URL parameters, and then return raw image data as a JPEG or GIF file.