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
In which event of the page viewstate is available?
What is asp.net futures?
What is the difference between ldap and active directory?
What is difference cookie and session?
What is the main difference between Asp.net and Vb.net?
What are tuples?
How to implement role based security in asp.net mvc? : Asp.Net MVC
Apart from IDE what are the enhancements in asp.net 2.0?
What is http post action?
Can you use Web API with ASP.NET Web Form?
What are the different types of validation controls provided in ASP.NET?
Explain difference between friend and protected friend?
A Web Service Can Only Be Written In .net. Is it True??
Demonstrate Render and PreRender?
Why do you use the app_code folder in asp.net?