.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Interview Question >> ASP.Net >> Post New Question Subscribe to Interview Questions

What is the difference between web.config and global.asax?

Posted By :ASPEvil     Posted Date :July 24, 2014    Points :40   Category :ASP.Net 
web.config:- It is a xml based file.
glbal.asax:- It is class file.

web.config:- It carries configuration data of the ASP.Net website.
global.asax:- It carries application events of the ASP.Net website.

web.config:- If there will be any change made on this file, we need to just save the new file with the ASP.Net website.
global.asax:- If there will be any change made on this file, we need to compile/rebuild the ASP.Net website.

You can also find related Interview Question to What is the difference between web.config and global.asax?  below: 

Difference Between Web.Config file and Global.asax ?

Web.Config file is used ....

1. To specify the application settings
2. To specify the session mechanism available to use for that application.
3. To Specify the Connection strings.
4. To Specify the authentication and authorization.
5. To Specify the http handlers.
6. To Specify different providers.

Global.asax file is used to specify the session and application event handlers.

List the event handlers that can be included in Global.asax?

o Application start and end event handlers
o Session start and end event handlers
o Per-request event handlers
o Non-deterministic event handlers (More...)

Why is Global.asax is used for ?

Global.asax is used To implement application & Session level events (More...)

What is the difference between "Web.config" and "Machine.Config" ?

Configuration files are used to control and manage the behavior of a web application.
1. Machine.config
2. Web.config


One Machine.config file is shared for all ASP.NET's Application. It is only one on the machine for each version of .NET Framework. If you apply anything in machine.config file then it is applied on all ASP.NET applications. Machine.config file is universal on the machine. It can be located in the %runtime install path%\Config directory.

1. This is automatically installed when you install .NET Framework or Visual Studio. Net.
2. This is also called machine level configuration file.
3. Only one machine.config file exists on a server/computer.
4. This file is at the highest level in the configuration hierarchy

Web.config file is only for particular ASP.NET application. each ASP.NET application has different file. One ASP.NET application can have more than one web.config file. But only one in one folder.

1. This is automatically created when you create an ASP.Net web application project.
2. This is also called application level configuration file or folder level configuration file.
3. This file inherits setting from the machine.config. If same setting key is defined in both Machine.Config and Web.config, the Web.Config setting is used.

Difference Between Machine.config and Web.config

Machine.config is automatically installed when you install .NET Framework or Visual Studio. Net.

Web.config is automatically created when you create an ASP.Net web application project.

Machine.config is called machine level configuration file. Only one machine.config file exists on a server.

Web.config is called application level configuration file.

Machine.config file is at the highest level in the configuration hierarchy.

Web.Config file inherits setting from the machine.config (More...)

What event handlers can I include in Global.asax?

Application_Start,Application_End, Application_AcquireRequestState, Application_AuthenticateRequest, Application_AuthorizeRequest, Application_BeginRequest, Application_Disposed, Application_EndRequest, Application_Error, Application_PostRequestHandlerExecute, Application_PreRequestHandlerExecute,
Application_PreSendRequestContent, Application_PreSendRequestHeaders, Application_ReleaseRequestState, Application_ResolveRequestCache, Application_UpdateRequestCache, Session_Start,Session_End
You can optionally include "On" in any of method names. For example, you can name a BeginRequest event handler.Application_BeginRequest or Application_OnBeginRequest.You can also include event handlers in Global.asax for events fired by custom HTTP modules.Note that not all of the event handlers make sense for Web Services (they're designed for ASP.NET applications in general, whereas .NET XML Web Services are specialized instances of an ASP.NET app). For example, the Application_AuthenticateRequest and Application_AuthorizeRequest events are designed to be used with ASP.NET Forms authentication.

Difference Between Machine.config and Web.config?

Machine.config->Configuration file for all the applications in the system.
Web.config->Config file for single application. (More...)

What is the difference between a local and a global variable?

A local temporary table exists only for the duration of a connection or, if defined inside a compound statement, for the duration of the compound statement.
A global temporary table remains in the database permanently, but the rows exist only within a given connection. When connection are closed, the data in the global temporary table disappears. However, the table definition remains with the database for access when database is opened next time. (More...)

What is the difference between Machine.config and web.config?

The main difference between Machine.config and web.config is as follows:
Machine.config is machine level config file,means if you make any changes into this file, it will applicable for all application which exists on same machine.

While Web.config settings only applicable for application level.This file is best place to keep your connection string and SMTP like settings and so on. (More...)

List major events in GLOBAL.ASAX file ?

thus bypassing handler execution.
Web site. (More...)

What's the significance of "GLOBAL.ASAX" file ?

GLOBAL.ASAX allows us to executing ASP.NET application level events and setting application-level variables. (More...)

Difference between "Web.config" and "Machine.Config" ?

"Web.config" applies settings to each web application, while "Machine.config" applies settings to all ASP.NET applications. (More...)

Difference between web.config and app.config?

web.Config -- used in Web Application
app.config -- used in Windows application (More...)

What is Global.asax used for?

implement application and session level events. (More...)

Quick Links For Interview Questions Categories:
ASP.Net Windows Application   .NET Framework   C#   VB.Net   ADO.Net  
Sql Server   SharePoint   Silverlight   OOPs   JQuery   JavaScript/VBScript
Biztalk Patten/Practices .IIS WCF WPF WWF
Networking Aptitude Others   All      

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend