HighTechTalks DotNet Forums  

Writing connection string in web.config

ASP.net ASP.net discussions (microsoft.public.dotnet.framework.aspnet)


Discuss Writing connection string in web.config in the ASP.net forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
WT
 
Posts: n/a

Default Writing connection string in web.config - 05-30-2006 , 11:19 AM






Hello,

I am writing a Web install project and I want to get the connection string
from user and write it in the web.config of the installed web site.
As the Websetup is a windows program, I use a windows program to get the
string and I don't know if I can use the WebConfigurationManager API to read
and write my web config from a windows program.
What is the prefered .NET 2 way to handle this necessary install problem
without asking users to open web.config and write the connection stri ng in
the ConnectionString section by hand..

Thanks for help
CS



Reply With Quote
  #2  
Old   
Marina Levit [MVP]
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 11:44 AM






If you put it into web.config, that will immediately restart asp.net. I
would not recommend doing this.

If the user is going to change this on the fly, I would create a separate
file, and write to it. Just make sure that it is secured such that someone
can't create an http request and ask for it. I think maybe .config files
are protected automatically, so maybe you can call it myConnString.config,
and have IIS take care of this for you (double check this).

"WT" <WT (AT) newsgroups (DOT) nospam> wrote

Quote:
Hello,

I am writing a Web install project and I want to get the connection string
from user and write it in the web.config of the installed web site.
As the Websetup is a windows program, I use a windows program to get the
string and I don't know if I can use the WebConfigurationManager API to
read and write my web config from a windows program.
What is the prefered .NET 2 way to handle this necessary install problem
without asking users to open web.config and write the connection stri ng
in the ConnectionString section by hand..

Thanks for help
CS




Reply With Quote
  #3  
Old   
WT
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 11:55 AM



Thanks for answer but you have not understood my problem, may be badly
explained, my fault.

I am installing a web site using a web setup program built with VS2005.
Nothing is running, the setup process has just copied the files in the
desired server folder, and the GetLicence Dialog is ran to get the SQL
connection string from user.

CS


"Marina Levit [MVP]" <someone (AT) nospam (DOT) com> a écrit dans le message de news:
eti9AAAhGHA.1324 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
If you put it into web.config, that will immediately restart asp.net. I
would not recommend doing this.

If the user is going to change this on the fly, I would create a separate
file, and write to it. Just make sure that it is secured such that
someone can't create an http request and ask for it. I think maybe
.config files are protected automatically, so maybe you can call it
myConnString.config, and have IIS take care of this for you (double check
this).

"WT" <WT (AT) newsgroups (DOT) nospam> wrote in message
news:%23h1vrx$gGHA.2188 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Hello,

I am writing a Web install project and I want to get the connection
string from user and write it in the web.config of the installed web
site.
As the Websetup is a windows program, I use a windows program to get the
string and I don't know if I can use the WebConfigurationManager API to
read and write my web config from a windows program.
What is the prefered .NET 2 way to handle this necessary install problem
without asking users to open web.config and write the connection stri ng
in the ConnectionString section by hand..

Thanks for help
CS






Reply With Quote
  #4  
Old   
Marina Levit [MVP]
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 12:25 PM



Oh, I see. Sorry for misunderstanding.

As far as I know, there is no API for writing to the .config file. You'll
need to just load it up into an XML dom, manipulate it, and save it back.

"WT" <WT (AT) newsgroups (DOT) nospam> wrote

Quote:
Thanks for answer but you have not understood my problem, may be badly
explained, my fault.

I am installing a web site using a web setup program built with VS2005.
Nothing is running, the setup process has just copied the files in the
desired server folder, and the GetLicence Dialog is ran to get the SQL
connection string from user.

CS


"Marina Levit [MVP]" <someone (AT) nospam (DOT) com> a écrit dans le message de news:
eti9AAAhGHA.1324 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
If you put it into web.config, that will immediately restart asp.net. I
would not recommend doing this.

If the user is going to change this on the fly, I would create a separate
file, and write to it. Just make sure that it is secured such that
someone can't create an http request and ask for it. I think maybe
.config files are protected automatically, so maybe you can call it
myConnString.config, and have IIS take care of this for you (double check
this).

"WT" <WT (AT) newsgroups (DOT) nospam> wrote in message
news:%23h1vrx$gGHA.2188 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Hello,

I am writing a Web install project and I want to get the connection
string from user and write it in the web.config of the installed web
site.
As the Websetup is a windows program, I use a windows program to get the
string and I don't know if I can use the WebConfigurationManager API to
read and write my web config from a windows program.
What is the prefered .NET 2 way to handle this necessary install problem
without asking users to open web.config and write the connection stri ng
in the ConnectionString section by hand..

Thanks for help
CS








Reply With Quote
  #5  
Old   
Edwin Knoppert
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 01:57 PM



Quote:
I am writing a Web install project and I want to get the connection string
from user and write it in the web.config
Why?
Relative folder is allowed nativly.



"WT" <WT (AT) newsgroups (DOT) nospam> schreef in bericht
news:%23h1vrx$gGHA.2188 (AT) TK2MSFTNGP04 (DOT) phx.gbl...
Quote:
Hello,

I am writing a Web install project and I want to get the connection string
from user and write it in the web.config of the installed web site.
As the Websetup is a windows program, I use a windows program to get the
string and I don't know if I can use the WebConfigurationManager API to
read and write my web config from a windows program.
What is the prefered .NET 2 way to handle this necessary install problem
without asking users to open web.config and write the connection stri ng
in the ConnectionString section by hand..

Thanks for help
CS




Reply With Quote
  #6  
Old   
WT
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 03:54 PM



What do you call relative folder ?
Sometime several SQL servers are available, and different connection
strings.
CS

"Edwin Knoppert" <info (AT) pbsoft (DOT) speedlinq.nl> a écrit dans le message de news:
e5i12i$50t$1 (AT) azure (DOT) qinip.net...
Quote:
I am writing a Web install project and I want to get the connection
string from user and write it in the web.config
Why?
Relative folder is allowed nativly.




Reply With Quote
  #7  
Old   
Edwin Knoppert
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-30-2006 , 04:21 PM



The original post was unclear to me.
I see you really want to write it, and not using
datasource=|DataDirectory|... stuff.
Ok.



"WT" <WT (AT) newsgroups (DOT) nospam> schreef in bericht
news:OekgnLChGHA.3588 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
Quote:
What do you call relative folder ?
Sometime several SQL servers are available, and different connection
strings.
CS

"Edwin Knoppert" <info (AT) pbsoft (DOT) speedlinq.nl> a écrit dans le message de
news: e5i12i$50t$1 (AT) azure (DOT) qinip.net...
I am writing a Web install project and I want to get the connection
string from user and write it in the web.config
Why?
Relative folder is allowed nativly.






Reply With Quote
  #8  
Old   
AT
 
Posts: n/a

Default RE: Writing connection string in web.config - 05-31-2006 , 03:10 AM




Hi,

Thank you for your post!

Although in .NET 2.0 we can use WebConfigurationManager API to read/write
the web.config via code, currently
WebConfigurationManager.OpenWebConfiguration() can only use virtual path to
access web.config. Since you are running a Windows application, I'm afraid
this approach will not be applicable.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #9  
Old   
WT
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-31-2006 , 06:27 AM



I will use an XML approch better adapted.
Dommage.
CS
"Walter Wang [MSFT]" <wawang (AT) online (DOT) microsoft.com> a écrit dans le message
de news: vU7bUFIhGHA.2260 (AT) TK2MSFTNGXA01 (DOT) phx.gbl...
Quote:
Hi,

Thank you for your post!

Although in .NET 2.0 we can use WebConfigurationManager API to read/write
the web.config via code, currently
WebConfigurationManager.OpenWebConfiguration() can only use virtual path
to
access web.config. Since you are running a Windows application, I'm afraid
this approach will not be applicable.


Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.




Reply With Quote
  #10  
Old   
AT
 
Posts: n/a

Default Re: Writing connection string in web.config - 05-31-2006 , 09:58 PM



Thank you for your update.

Please feel free to post here if you have any question about the XML
approach.

Regards,
Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.