SlideShare a Scribd company logo
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 (20)

PPTX
Creational pattern
Himanshu
 
PPT
Servlets
Sasidhar Kothuru
 
PPTX
Java Server Pages(jsp)
Manisha Keim
 
PDF
Java Collection framework
ankitgarg_er
 
PPTX
Introduction to mvc architecture
ravindraquicsolv
 
PPT
Collection Framework in java
CPD INDIA
 
PPT
Asp.net server controls
Raed Aldahdooh
 
PDF
MVC Architecture
Prem Sanil
 
PPT
Spring ppt
Mumbai Academisc
 
PPTX
ASP.NET Page Life Cycle
Abhishek Sur
 
PPSX
ASP.NET Web form
Md. Mahedee Hasan
 
PPT
Mvc architecture
Surbhi Panhalkar
 
PPTX
ASP.NET MVC.
Ni
 
PPT
Asp.net architecture
Iblesoft
 
PPSX
ADO.NET
Farzad Wadia
 
PDF
Asp.net state management
priya Nithya
 
PPTX
Ajax
Tech_MX
 
Creational pattern
Himanshu
 
Java Server Pages(jsp)
Manisha Keim
 
Java Collection framework
ankitgarg_er
 
Introduction to mvc architecture
ravindraquicsolv
 
Collection Framework in java
CPD INDIA
 
Asp.net server controls
Raed Aldahdooh
 
MVC Architecture
Prem Sanil
 
Spring ppt
Mumbai Academisc
 
ASP.NET Page Life Cycle
Abhishek Sur
 
ASP.NET Web form
Md. Mahedee Hasan
 
Mvc architecture
Surbhi Panhalkar
 
ASP.NET MVC.
Ni
 
Asp.net architecture
Iblesoft
 
ADO.NET
Farzad Wadia
 
Asp.net state management
priya Nithya
 
Ajax
Tech_MX
 

Viewers also liked (20)

PPT
Asp.net
Dinesh kumar
 
PPT
Developing an ASP.NET Web Application
Rishi Kothari
 
PPTX
Harish Understanding Aspnet
rsnarayanan
 
PPTX
Skillwise - Advanced web application development
Skillwise Group
 
PPT
Beginning asp.net application Development with visual studio 2013
Abhijit B.
 
PPTX
Asp.net and .Net Framework ppt presentation
abhishek singh
 
PPTX
Directives in asp.net
Sireesh K
 
PPTX
Ch06 ado.net fundamentals
Madhuri Kavade
 
PPS
Vb.net session 05
Niit Care
 
PPTX
Introduction to asp.net
shan km
 
PDF
Asp dot net final (2)
Amelina Ahmeti
 
PPT
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
PPTX
Introduction to ASP.NET
Peter Gfader
 
PPTX
ASP.NET State management
Shivanand Arur
 
PPT
Be project ppt asp.net
Sanket Jagare
 
PPTX
IPSec and VPN
Abdullaziz Tagawy
 
PPTX
Introduction to asp.net
Melick Baranasooriya
 
PPTX
Developing an aspnet web application
Rahul Bansal
 
PPTX
RESTful API Design Best Practices Using ASP.NET Web API
💻 Spencer Schneidenbach
 
PPT
ASP.NET Tutorial - Presentation 1
Kumar S
 
Asp.net
Dinesh kumar
 
Developing an ASP.NET Web Application
Rishi Kothari
 
Harish Understanding Aspnet
rsnarayanan
 
Skillwise - Advanced web application development
Skillwise Group
 
Beginning asp.net application Development with visual studio 2013
Abhijit B.
 
Asp.net and .Net Framework ppt presentation
abhishek singh
 
Directives in asp.net
Sireesh K
 
Ch06 ado.net fundamentals
Madhuri Kavade
 
Vb.net session 05
Niit Care
 
Introduction to asp.net
shan km
 
Asp dot net final (2)
Amelina Ahmeti
 
The complete ASP.NET (IIS) Tutorial with code example in power point slide show
Subhas Malik
 
Introduction to ASP.NET
Peter Gfader
 
ASP.NET State management
Shivanand Arur
 
Be project ppt asp.net
Sanket Jagare
 
IPSec and VPN
Abdullaziz Tagawy
 
Introduction to asp.net
Melick Baranasooriya
 
Developing an aspnet web application
Rahul Bansal
 
RESTful API Design Best Practices Using ASP.NET Web API
💻 Spencer Schneidenbach
 
ASP.NET Tutorial - Presentation 1
Kumar S
 
Ad

Similar to Ch 04 asp.net application (20)

PPTX
Chapter 5
application developer
 
PDF
ASP.NET Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
ASP.NET Unit-2.pdf
abiraman7
 
PPT
Asp dot net long
Amelina Ahmeti
 
PPS
01 asp.net session01
Mani Chaubey
 
PPTX
Aspnet architecture
phantrithuc
 
PPTX
ASP.NET Presentation
dimuthu22
 
PPTX
Programming web application
aspnet123
 
PPSX
01 asp.net session01
Vivek Singh Chandel
 
PPTX
Asp.net
vijilakshmi51
 
PDF
Asp .net web form fundamentals
Gopal Ji Singh
 
PPT
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
Anwar Patel
 
PPT
Asp.net control
Paneliya Prince
 
PDF
Asp.netrole
mani bhushan
 
PPT
SynapseIndia dotnet website security development
Synapseindiappsdevelopment
 
PPTX
Unit - 1: ASP.NET Basic
KALIDHASANR
 
PDF
Asp.Net 3 5 Part 1
asim78
 
PPTX
asp.net Webconfiguration
Ma Kik
 
ASP.NET Interview Questions PDF By ScholarHat
Scholarhat
 
ASP.NET Unit-2.pdf
abiraman7
 
Asp dot net long
Amelina Ahmeti
 
01 asp.net session01
Mani Chaubey
 
Aspnet architecture
phantrithuc
 
ASP.NET Presentation
dimuthu22
 
Programming web application
aspnet123
 
01 asp.net session01
Vivek Singh Chandel
 
Asp.net
vijilakshmi51
 
Asp .net web form fundamentals
Gopal Ji Singh
 
asp-2005311dgvdfvdfvfdfvdvfdbfdb03252 (1).ppt
Anwar Patel
 
Asp.net control
Paneliya Prince
 
Asp.netrole
mani bhushan
 
SynapseIndia dotnet website security development
Synapseindiappsdevelopment
 
Unit - 1: ASP.NET Basic
KALIDHASANR
 
Asp.Net 3 5 Part 1
asim78
 
asp.net Webconfiguration
Ma Kik
 
Ad

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.