web.config in separte directory

G

Guest

Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named Secure.

I have a web.config in each of the above directories. The web.config in the
Secure directory contains the connection string information for the database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the AspNet
worker process id to avoid most everyone from having access to the Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
J

Juan T. Llibre

re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





theWizard1 said:
Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named Secure.

I have a web.config in each of the above directories. The web.config in the
Secure directory contains the connection string information for the database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the AspNet
worker process id to avoid most everyone from having access to the Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
G

Guest

Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

Juan T. Llibre said:
re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





theWizard1 said:
Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named Secure.

I have a web.config in each of the above directories. The web.config in the
Secure directory contains the connection string information for the database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the AspNet
worker process id to avoid most everyone from having access to the Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
J

John Timney \( MVP \)

string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

theWizard1 said:
Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

Juan T. Llibre said:
re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





theWizard1 said:
Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named
Secure.

I have a web.config in each of the above directories. The web.config
in the
Secure directory contains the connection string information for the
database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
G

Guest

Can someone put the complete answer together for me. I do not seem to get
the whole picture. We are using Asp.Net 1.1 and SqlServer 2000.

We have a web.config file on application website, and a web.config file iin
a subdirectory named Secure on the website

The web.config in the Secure subdirectory contains the following:

<appSettings>
<add key="ConnectionString" value="server=myserver;database=mydatabase;user
id=theuserid;
password=mypassword;" />
</appSettings>

How do I get the connection string from the Secure subdirectory.

The 2 previous answers are showing how to connection string and how to get a
path, but neither puts the 2 together. Can I use a ~ for a relative path.
Please help. The web.config in the website directory does not contain any
connection string.

John Timney ( MVP ) said:
string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

theWizard1 said:
Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

Juan T. Llibre said:
re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named
Secure.

I have a web.config in each of the above directories. The web.config
in the
Secure directory contains the connection string information for the
database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
J

Juan T. Llibre

re:
The web.config in the website directory does not contain any connection string.

What's stopping you from including the
connection string in the website directory's web.config ?




theWizard1 said:
Can someone put the complete answer together for me. I do not seem to get
the whole picture. We are using Asp.Net 1.1 and SqlServer 2000.

We have a web.config file on application website, and a web.config file iin
a subdirectory named Secure on the website

The web.config in the Secure subdirectory contains the following:

<appSettings>
<add key="ConnectionString" value="server=myserver;database=mydatabase;user
id=theuserid;
password=mypassword;" />
</appSettings>

How do I get the connection string from the Secure subdirectory.

The 2 previous answers are showing how to connection string and how to get a
path, but neither puts the 2 together. Can I use a ~ for a relative path.
Please help. The web.config in the website directory does not contain any
connection string.

John Timney ( MVP ) said:
string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

theWizard1 said:
Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

:

re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named
Secure.

I have a web.config in each of the above directories. The web.config
in the
Secure directory contains the connection string information for the
database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
G

Guest

We were planning to place additional security on the Secure directory. And,
granting permissions to the ASP.net account as a user through Windows
Security. In other words, revoke permissions for everyone on the Secure
directory, and grant permissions to the Asp.Net account.

Juan T. Llibre said:
re:
The web.config in the website directory does not contain any connection string.

What's stopping you from including the
connection string in the website directory's web.config ?




theWizard1 said:
Can someone put the complete answer together for me. I do not seem to get
the whole picture. We are using Asp.Net 1.1 and SqlServer 2000.

We have a web.config file on application website, and a web.config file iin
a subdirectory named Secure on the website

The web.config in the Secure subdirectory contains the following:

<appSettings>
<add key="ConnectionString" value="server=myserver;database=mydatabase;user
id=theuserid;
password=mypassword;" />
</appSettings>

How do I get the connection string from the Secure subdirectory.

The 2 previous answers are showing how to connection string and how to get a
path, but neither puts the 2 together. Can I use a ~ for a relative path.
Please help. The web.config in the website directory does not contain any
connection string.

John Timney ( MVP ) said:
string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

:

re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named
Secure.

I have a web.config in each of the above directories. The web.config
in the
Secure directory contains the connection string information for the
database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
J

John Timney \( MVP \)

Your trying to reinvent the wheel - web.config is already prohibited from
direct access to remote users.

--
Regards

John Timney
Microsoft MVP

theWizard1 said:
We were planning to place additional security on the Secure directory.
And,
granting permissions to the ASP.net account as a user through Windows
Security. In other words, revoke permissions for everyone on the Secure
directory, and grant permissions to the Asp.Net account.

Juan T. Llibre said:
re:
The web.config in the website directory does not contain any connection
string.

What's stopping you from including the
connection string in the website directory's web.config ?




theWizard1 said:
Can someone put the complete answer together for me. I do not seem to
get
the whole picture. We are using Asp.Net 1.1 and SqlServer 2000.

We have a web.config file on application website, and a web.config file
iin
a subdirectory named Secure on the website

The web.config in the Secure subdirectory contains the following:

<appSettings>
<add key="ConnectionString"
value="server=myserver;database=mydatabase;user
id=theuserid;
password=mypassword;" />
</appSettings>

How do I get the connection string from the Secure subdirectory.

The 2 previous answers are showing how to connection string and how to
get a
path, but neither puts the 2 together. Can I use a ~ for a relative
path.
Please help. The web.config in the website directory does not contain
any
connection string.

:

string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

:

re;
How can I use ConfigurationSettings.AppSettings to show the path
of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





message
Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it
named
Secure.

I have a web.config in each of the above directories. The
web.config
in the
Secure directory contains the connection string information for
the
database.


How can I use ConfigurationSettings.AppSettings to show the path
of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to
the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 
J

Juan T. Llibre

re:
We were planning to place additional security on the Secure directory.

You can still do that, even if the connection string is available in the less-secure directory.

Anybody could access the more secure directory.
Only those with enough permissions should see the secure content in it.

You could, for example, allow opening a page -which anybody can see-
in the secure directory but, to see any other page, you'd need appropiate credentials.

Look into using forms-based authentication.

Michelle Leroux's article will give you some ideas on how to implement it :
http://www.theserverside.net/articles/showarticle.tss?id=FormAuthentication





theWizard1 said:
We were planning to place additional security on the Secure directory. And,
granting permissions to the ASP.net account as a user through Windows
Security. In other words, revoke permissions for everyone on the Secure
directory, and grant permissions to the Asp.Net account.

Juan T. Llibre said:
re:
The web.config in the website directory does not contain any connection string.

What's stopping you from including the
connection string in the website directory's web.config ?




theWizard1 said:
Can someone put the complete answer together for me. I do not seem to get
the whole picture. We are using Asp.Net 1.1 and SqlServer 2000.

We have a web.config file on application website, and a web.config file iin
a subdirectory named Secure on the website

The web.config in the Secure subdirectory contains the following:

<appSettings>
<add key="ConnectionString" value="server=myserver;database=mydatabase;user
id=theuserid;
password=mypassword;" />
</appSettings>

How do I get the connection string from the Secure subdirectory.

The 2 previous answers are showing how to connection string and how to get a
path, but neither puts the 2 together. Can I use a ~ for a relative path.
Please help. The web.config in the website directory does not contain any
connection string.

:

string secureDirectory =
ConfigurationSettings.AppSettings["secureDirectory"];

--
Regards

John Timney
Microsoft MVP

Please provide an example of getting the connection string from the
MyApp\Secure\Web.Config directory.

:

re;
How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Why do you want to get the path of your secure directory in the
connection string?

A connection string, unless used for Access or
SQL Server Express databases doesn't store database paths.

If you want a *path* to the secure directory,
store the path in the appSettings section of web.config.

<appSettings>
<add key="secureDirectory" value="/YourApp/SecureDirectory" />
</appSettings>

Then, you can use that path anywhere you want to in your app.





Using Asp.NET 1.1, and C#.

I have a directory for the website, and a directory under it named
Secure.

I have a web.config in each of the above directories. The web.config
in the
Secure directory contains the connection string information for the
database.


How can I use ConfigurationSettings.AppSettings to show the path of the
Secure directory when getting the connection string?

Shown below is a sample, but it is not passing the path.

We plan to use Windows security on the Secure folder, and add the
AspNet
worker process id to avoid most everyone from having access to the
Secure
folder contents.

web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user
id=...;
password=...;" />
</appSettings>

In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top