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
What should you do is you want to remove an existing component but would like to make some funtionalities?
How do I know asp.net mvc version? : Asp.Net MVC
Explain the function of new view engine in asp.net? : asp.net mvc
What is application session?
What is another word for redirect?
In a Repeater control how one can provide an alternating color scheme ?
Can you set the session out time manually?
If iam developing an application that must accomodate multiple security levels though secure login and my asp.net web appplication is spanned across three web-servers (using round-robbin load balancing) what would be the best approach to maintain login-in state for the users?
What are the asp.net list controls and difference between them?
Differentiate strong typing and weak typing
Where is http session stored?
How can we inherit a static member?
What is authorization in asp.net?
Explain the role of global.asax?
How to use ipostback?