What is the Difference between Web.config and global.asax?
Can we write connection String code in global.asax?
Answer Posted / nidhi
Global.asax files allows you to executing ASP.Net application level events and setting application level variable.
The web.config file uses a predefined XML format. The entire content of the file is nested in a
root <configuration> element.
We can create more than one web.config file but we can't have more than one Global.asax file.
Yes we can write connection string in Global.asax file.
First store connection string in web.config file and fetch
in a Global.asax file using below code.
In global.asax
Application["VariableName"] = ConfigurationManager.ConnectionStrings["ConnStr"].
ConnectionString;
Now to fetch the value from applictaion variable
string conn = Application["VariableName"].ToString();
Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Will the asp.net validators run in server side or client side? How do you do client-side validation in .net?
What are assemblies and namespaces and explain the difference between them ?
Explain the updatepanel?
What is the use of global.asax file?
What do you mean by marshalbyref?
What is the file extension of web service?
If I have more than one version of one assemblies, then how will I use old version (how/where to specify version number?) In my application?
How can i explain my project during interview?many time i expalain my project but they did't accept? please explain me.
Where can I get information on cookies in asp.net?
What is the difference between file-based dependency and key-based dependency?
What is sql data source control in asp.net?
What is difference between session and cookie?
What is redirectpermanent in asp.net?
What are the types of caching in asp.net?
Describe in brief .net framework and its components.