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
Difference between DataGid and Girdview? Difference b/w .Net 2.0, 3.0 and 3.5 ? Diff b/w dispose & Finialize Methods?
How to rename a table using sql queries?
What is the purpose of using MVC programming pattern in ASP.NET?
What is an axd file?
Explain how can we inherit a static member?
Is it possible to migrate visual interdev design-time controls to asp.net?
To display data in the combo box, prior to setting the Data Source, what kind of property on a Combo Box do you set with a column name?
Why is xap important?
What is the concepts of globalization and localization in .net?
What threading model used in asp and asp.net?
How you can access the values from the Repeater control in ASP.NET?
Can you explain the importance of finalize method in .net?
What is form submit?
How to find last error which occurred in Asp.net ?
Less than one page, how many windows will you be able to maintain?