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
How do cookies work? Give an example of their abuse.
Why do you use the app_code folder in asp.net?
What are the uses of list view control in Asp.net?
What are strong names?
What is the use of worker process in asp.net?
Can you dynamically assign a Master Page?
What is css and what is it used for?
benefits of migration from asp to asp.net hi frnds, i have to give presentation to a client about how useful would be migrating their project from asp to asp.net .plz give me some points which i should incorporate in my ppt thanks
Why we are using mvc instead of asp.net? : Asp.Net MVC
What is sql data source control in asp.net?
What are validators and list some validators of asp.net?
What are cao and sao.
How many types of controls are there in asp.net?
Should I delete cookies?
List the types of authentication supported by asp.net?