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
Let's say I have an existing application written using vb6 and this application utilizes windows 2000 com+ transaction services. How would you approach migrating this application to.net?
How does session state work in asp.net?
How is application management and maintenance improved in asp.net 2.0?
What is & in a url?
What is server infrastructure?
What is cas?
What is the best Macanism to clear the Cache in asp.net
List down the sequence of methods called during the page load.
What are merge modules?
What’s the difference between response .redirect and server.transfer?
Explain the difference between webfarm and webgardens in .net?
Which is an advantage of application service providers?
Why is mvc better than asp.net?
Describe the differences between the lifecycles of Windows services and Standard EXE?
What is the use of placeholder control? Can we see it at runtime?