Re: Connection string issue when in a separate web.config
- From: theWizard1 <theWizard1@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 24 Apr 2006 13:23:02 -0700
I believe we have found the answer: Just add Network Service, and remove
everyone.
Again, Dominick thank you for the answer regarding my first question. You
are .net rocking!
"theWizard1" wrote:
Your answer worked. However, now I need to know how to configure permissions.
on the Secure directory.
We are using Windows 2003, and IIS6. What do we need to do regarding
permissions for the Secure folder.
"Dominick Baier [DevelopMentor]" wrote:
hi,
the indexer on .ConnectionStrings expects the name of the connection string,
in your case "myConnectionString".
that said - which config entries WebConfigurationManager/ConfigurationManager
can "see" depends on the location from where they were called
if you want to access the connection string that is stored in ~/secure from
~/someOtherDir - this want work e.g.
you can explicitly open the config file
Configuration c = WebConfigurationManager.OpenWebConfiguration("~/secure");
return c.ConnectionStrings.ConnectionStrings["data"].ConnectionString;
or just store the connection string in the root directory where it will be
used...
---------------------------------------
Dominick Baier - DevelopMentor
http://www.leastprivilege.com
Using asp.net 2.0, visualstudio .net 2005, sqlserver2000.
How do I get the myConnectionString when it is in a Web.Config located
in a different folder. I used the following but it is not working.
I have a App_Code\DAL folder. Inside it, I have a Db.cs file. I
tried the following in the DB.cs file.
//Get default connection string
connectionString =
WebConfigurationManager.ConnectionStrings["~/Secure/myConnectionString
"].ConnectionString;
I have created a folder inside my website folder, named Secure, and
placed a web.cofig file that contains the following in the Secure
folder.
<?xml version="1.0"?>
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="myConnectionString"
connectionString="Data
Source=MyDomain\MyServerName;Database=MydatabaseName;uid=xxx;pwd=xx;"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
</system.web>
</configuration>
My website contains a web.config file with the following contents:
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly"
defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
<system.net>
<mailSettings>
<smtp from="">
<network host="smtp.myServer.com" password="" userName="" />
</smtp>
</mailSettings>
</system.net>
</configuration>
- References:
- Connection string issue when in a separate web.config
- From: theWizard1
- Re: Connection string issue when in a separate web.config
- From: Dominick Baier [DevelopMentor]
- Re: Connection string issue when in a separate web.config
- From: theWizard1
- Connection string issue when in a separate web.config
- Prev by Date: Re: Connection string issue when in a separate web.config
- Next by Date: Re: Connection string issue when in a separate web.config
- Previous by thread: Re: Connection string issue when in a separate web.config
- Next by thread: Re: Connection string issue when in a separate web.config
- Index(es):
Relevant Pages
|