473,406 Members | 2,956 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Access web.config from lower folder?

I have a subfolder in a webapp

How can the aspx in the subfolder access the web.config in the webapp.

I.e. I stored the connectionstring in the \webapp\web.config
how the \webapp\subfolder\default.aspx extract the connection?

ConfigurationSettings.AppSettings["ConnectionString"] return empty string

Do I have to copy the web.config to the subfolder?
Nov 20 '05 #1
5 3663
no, web.config should be in the root folder of the app.
The way you mention should work - does
ConfigurationSettings.AppSettings["ConnectionString"] work in the
rootfolder ? (maybe something is wrong in the syntax of web.config)

Nov 20 '05 #2
seem that the ConfigurationSettings.AppSettings["ConnectionString"] is not
the correct statment to extract the string in asp.net 2.0, becos I cannot do
it even in webapp

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=...."
ProviderName="System.Data.SqlClient"/>
</connectionStrings>
"Jason Chan" <no@email.com> 撰寫於郵件新聞:%2****************@TK2MSFTNGP12.phx .gbl...
I have a subfolder in a webapp

How can the aspx in the subfolder access the web.config in the webapp.

I.e. I stored the connectionstring in the \webapp\web.config
how the \webapp\subfolder\default.aspx extract the connection?

ConfigurationSettings.AppSettings["ConnectionString"] return empty string

Do I have to copy the web.config to the subfolder?

Nov 20 '05 #3
re:
How can the aspx in the subfolder access the web.config in the webapp.
It does it without having to do anything special.

re: Do I have to copy the web.config to the subfolder?
No, you don't.

Check your syntax.

If you want to, post the web.config appSettings section
( change any sensitive information, like passwords, if any )
and the line of code which you are using to retrieve the info.

string connect = ConfigurationSettings.AppSettings["ConnectionString"];
returns empty and your web.config's appSettings have a key like :

<appSettings>
<add key="ConnectionString" value="SomeConnectionStringtoYourDB" />
</appSettings>

?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espa隳l : http://asp.net.do/foros/
======================================
"Jason Chan" <no@email.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...I have a subfolder in a webapp

How can the aspx in the subfolder access the web.config in the webapp.

I.e. I stored the connectionstring in the \webapp\web.config
how the \webapp\subfolder\default.aspx extract the connection?

ConfigurationSettings.AppSettings["ConnectionString"] return empty string

Do I have to copy the web.config to the subfolder?

Nov 20 '05 #4
You should have said you were using ASP.NET 2.0 from the start.

Actually, ConfigurationSettings.AppSettings["ConnectionString"]
WILL return data from an <appSettings...> section which does
*not* have the <connectionStrings> section.

If you *do* include a <connectionStrings> section, then you can use :

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

or

String connString =
ConfigurationManager.ConnectionStrings(ConnectionS tring).ConnectionString


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espa隳l : http://asp.net.do/foros/
======================================
"Jason Chan" <no@email.com> wrote in message news:uP**************@tk2msftngp13.phx.gbl...
seem that the ConfigurationSettings.AppSettings["ConnectionString"] is not
the correct statment to extract the string in asp.net 2.0, becos I cannot do
it even in webapp

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=...."
ProviderName="System.Data.SqlClient"/>
</connectionStrings>
"Jason Chan" <no@email.com> 撰寫於郵件新聞:%2****************@TK2MSFTNGP12.phx .gbl...
I have a subfolder in a webapp

How can the aspx in the subfolder access the web.config in the webapp.

I.e. I stored the connectionstring in the \webapp\web.config
how the \webapp\subfolder\default.aspx extract the connection?

ConfigurationSettings.AppSettings["ConnectionString"] return empty string

Do I have to copy the web.config to the subfolder?

Nov 20 '05 #5
thanks , it work
"Juan T. Llibre" <no***********@nowhere.com> 撰寫於郵件新聞:%2****************@TK2MSFTNGP09.phx .gbl...
You should have said you were using ASP.NET 2.0 from the start.

Actually, ConfigurationSettings.AppSettings["ConnectionString"]
WILL return data from an <appSettings...> section which does
*not* have the <connectionStrings> section.

If you *do* include a <connectionStrings> section, then you can use :

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

or

String connString =
ConfigurationManager.ConnectionStrings(ConnectionS tring).ConnectionString


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Espa隳l : http://asp.net.do/foros/
======================================
"Jason Chan" <no@email.com> wrote in message
news:uP**************@tk2msftngp13.phx.gbl...
seem that the ConfigurationSettings.AppSettings["ConnectionString"] is not
the correct statment to extract the string in asp.net 2.0, becos I cannot
do
it even in webapp

<configuration
xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings/>
<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=...."
ProviderName="System.Data.SqlClient"/>
</connectionStrings>
"Jason Chan" <no@email.com> 撰寫於郵件新聞:%2****************@TK2MSFTNGP12.phx .gbl...
I have a subfolder in a webapp

How can the aspx in the subfolder access the web.config in the webapp.

I.e. I stored the connectionstring in the \webapp\web.config
how the \webapp\subfolder\default.aspx extract the connection?

ConfigurationSettings.AppSettings["ConnectionString"] return empty string

Do I have to copy the web.config to the subfolder?


Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
1
by: Microsoft News | last post by:
I have a web server sitting on computer 1, (QA1). Out on the network on my main server I have a folder with a zip file in it. All I want is for the web services that are on the web server to pick...
0
by: Yogesh Pancholi | last post by:
For some unexplained reason, I am suddenly unable to browse to a virtual directory on my laptop. I have a number of sample websites to which I could happliy browse up until last week. As of Monday,...
3
by: Rachel | last post by:
Hi, I am using the data access application block successfully in our development environment, however when I deploy to our testing server as Private Assemblies I keep getting the following ...
3
by: serge calderara | last post by:
Dear all, How to configure in config file, the fact that all users get access to the root web folder but only some of them to a restricted forlder Any sample ? thnaks for your help regards...
16
by: JonnyD | last post by:
I am working on a project to build a reporting web app from an exsiting database that is controled by a local application. The application that has control over the database creates a lock file to...
1
by: Arun | last post by:
I have a folder Secured under the root folder of the project In the project root web.config authentication is given as <authentication mode="Forms"> <forms loginUrl="Login.aspx" timeout="15"...
7
by: Speech Lover | last post by:
I have problem writing content to a UNC file from my ASP.NET 1.1 application. This is on Windows server 2003 The event log says "X:\temp\abc.txt path not found" and stuff. Note that I have...
7
by: =?Utf-8?B?RG91Z2llIEJyb3du?= | last post by:
Hi I've written custom configuration section (inherits from System.Configuration.ConfigurationSection) to simplify the contents of the config file and to make life easier when accessing them in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.