Chapter 3
Chapter 3
Ans: In book
2) Event handling
Ans: book
From pdf
4)page class
Ans:From book
Q5. Explain the use of global.asx and web.config files in ASP.NET application.
Ans: 1.The Global.asax file, also known as the ASP.NET application file, is an optional file that contains
code for responding to application-level events raised by ASP.NET or by HttpModules.
The Global.asax file resides in the root directory of an ASP.NET-based application. The
Global.asax file is parsed and dynamically compiled by ASP.NET.
The Global.asax file itself is configured so that any direct URL request for it is automatically
rejected; external users cannot download or view the code written within it.
The Global.asax file does not need recompilation if no changes have been made to it. There can
be only one Global.asax file per application and it should be located in the application's root
directory only.
Application_BeginRequest() – This event raised at the start of every request for the web application.
Application_EndRequest() – This event raised at the end of each request right before the objects
released.
Application_PostRequestHandlerExecute() – This event called just after the request is handled by its
appropriate HTTP handler.
Session_Start() – This event raised for each time a new session begins, This is a good place to put code
that is session-specific.
Application_Error() – This event raised whenever an unhandled exception occurs in the application. This
provides an opportunity to implement generic application-wide error handling.
Application_End() – This event raised just before when web application ends.
Application_Disposed() – This event fired after the web application is destroyed and this event is used to
reclaim the memory it occupies.
Web.Config
Configuration file is used to manage various settings that define a website. The settings are
stored in XML files that are separate from our application code. In this way we can configure
settings independently from our code.
Generally a website contains a single Web.config file stored inside the application root
directory. However there can be many configuration files that manage settings at various levels
within an application.
There are number of important settings that can be stored in the configuration file. Some of the
most frequently used configurations, stored conveniently inside Web.config file are:
- Database connections
- Caching settings
- Session States
- Error Handling
- Security
ASP.NET Configuration system is extensible and application specific information can be stored
and retrieved easily. It is human readable.
We need not restart the web server when the settings are changed in configuration file.
ASP.NET automatically detects the changes and applies them to the running ASP.NET
application.