I am about to deploy my first ASP.NET project.
But, I was used to store my variables, such as connection strings, in the
global.asa file, in an application. However, these variables are different
on my development and production server. If I use the global.asax file, then
it is in the code behing, compiled part. Thus I can't change the setting on
my production server.
So where is the right place to save my connecting string?
LeoThe Web.config file might be a good place. In the system.configuration
namespace, you can find the appropriate methods to access this file in you
application.
Regards,
Kristof
"Leo Muller" <leo-m@.keshet-i.com> wrote in message
news:c0su17$2d6$1@.news2.netvision.net.il...
> I am about to deploy my first ASP.NET project.
> But, I was used to store my variables, such as connection strings, in the
> global.asa file, in an application. However, these variables are different
> on my development and production server. If I use the global.asax file,
then
> it is in the code behing, compiled part. Thus I can't change the setting
on
> my production server.
> So where is the right place to save my connecting string?
> Leo
That's what I have done - here's part of my Web.config file:
<configuration>
<appSettings>
<add key="MyConnectionString" value="...the connection string goes
here..." />
</appSettings
I then retrieve it using
ConfigurationSettings.AppSettings["MyConnectionString"]
I also set the BuildAction property of the Web.config file to None, to stop
it overwriting the version on the live server.
Hope that helps!
"Kristof Van Praet" <kristof_vanpraet@.hotmail.com> wrote in message
news:ejsgHGV9DHA.3292@.TK2MSFTNGP11.phx.gbl...
> The Web.config file might be a good place. In the system.configuration
> namespace, you can find the appropriate methods to access this file in you
> application.
> Regards,
> Kristof
> "Leo Muller" <leo-m@.keshet-i.com> wrote in message
> news:c0su17$2d6$1@.news2.netvision.net.il...
> > I am about to deploy my first ASP.NET project.
> > But, I was used to store my variables, such as connection strings, in
the
> > global.asa file, in an application. However, these variables are
different
> > on my development and production server. If I use the global.asax file,
> then
> > it is in the code behing, compiled part. Thus I can't change the setting
> on
> > my production server.
> > So where is the right place to save my connecting string?
> > Leo
Hi,
This helped me out, it works fine.
thanks,
Leo
"Sheila Jones" <sheilavjones@.btopenworld.com> wrote in message
news:e11QaWV9DHA.1636@.TK2MSFTNGP12.phx.gbl...
> That's what I have done - here's part of my Web.config file:
> <configuration>
> <appSettings>
> <add key="MyConnectionString" value="...the connection string goes
> here..." />
> </appSettings>
> I then retrieve it using
> ConfigurationSettings.AppSettings["MyConnectionString"]
> I also set the BuildAction property of the Web.config file to None, to
stop
> it overwriting the version on the live server.
> Hope that helps!
>
> "Kristof Van Praet" <kristof_vanpraet@.hotmail.com> wrote in message
> news:ejsgHGV9DHA.3292@.TK2MSFTNGP11.phx.gbl...
> > The Web.config file might be a good place. In the system.configuration
> > namespace, you can find the appropriate methods to access this file in
you
> > application.
> > Regards,
> > Kristof
> > "Leo Muller" <leo-m@.keshet-i.com> wrote in message
> > news:c0su17$2d6$1@.news2.netvision.net.il...
> > > I am about to deploy my first ASP.NET project.
> > > But, I was used to store my variables, such as connection strings, in
> the
> > > global.asa file, in an application. However, these variables are
> different
> > > on my development and production server. If I use the global.asax
file,
> > then
> > > it is in the code behing, compiled part. Thus I can't change the
setting
> > on
> > > my production server.
> > > > So where is the right place to save my connecting string?
> > > > Leo
> >
Leo, use the web.config as follows:
<configuration>
<!-- application specific settings -->
<appSettings>
<add key="connectionString" value="user id=your
username;password=userpassword;initial catalog=nameofdatabase;data
source=servername;Connect Timeout=30" />
</appSettings>
<system.web
"Leo Muller" <leo-m@.keshet-i.com> wrote in message news:<c0su17$2d6$1@.news2.netvision.net.il>...
> I am about to deploy my first ASP.NET project.
> But, I was used to store my variables, such as connection strings, in the
> global.asa file, in an application. However, these variables are different
> on my development and production server. If I use the global.asax file, then
> it is in the code behing, compiled part. Thus I can't change the setting on
> my production server.
> So where is the right place to save my connecting string?
> Leo
0 comments:
Post a Comment