473,395 Members | 2,689 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,395 software developers and data experts.

Separate .config file


I am working on a web app that I want to be able to use a separate
config file on, in addition to the web.config file that's already
working in the application.

If I put the following in the web.config file (VS 2005, Framework 2.0),
I can retrieve the values fine:

<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>

I retrieve the value with this line in the codefile in one of the apps
on the page:

Session("MyExchangeServer") =
WebConfigurationManager.AppSettings("fileInputFold er").ToString

The placement of the above appsettings line is right after the
</system.webin the web.config file, and immediately before the
<system.netline.

Any of those values can be read with no problem if they're in the
web.config file.

I added a new item to my project, app.config.

It looks like this:

<?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>
<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>
<connectionStrings/>
<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="false" />
<!--
The <authenticationsection enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrorssection 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>

</configuration>
It returns this message when I try to load the page.

The format of a configSource file must be an element containing the name
of the section. (C:\Inetpub\wwwroot\test\App.config line 10)

The only thing I have changed from the original app.config file was
where appSettings was already in the file, in the form <appSettings/>.
Where you see the <appSettingsand the 3-4 lines followed by the
</appSettings>, I simply replaced it.

The exact error on the page is:

Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.

Parser Error Message: The format of a configSource file must be an
element containing the name of the section.

Source Error:
Line 8: \Windows\Microsoft.Net\Framework\v2.x\Config
Line 9: -->
Line 10: <configuration>
Line 11: <appSettings>
Line 12: <add key="fileInputFolder" value="C:\National City
Downloads\test"/>
Source File: C:\Inetpub\wwwroot\test\App.config Line: 10
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.210
Any idea what I am doing wrong on this? I'd like to do some more with
this alternate config file, but I'm just trying to get the simple stuff
to work, before I do anything else.

Thanks,

BC
Jun 5 '07 #1
3 10570
Blasting Cap,

The use of the ConfigSource attribute is as follows:

Each section that supports configSource gets specified as
<membership configSource="config\membership.config"/>

In the membership.config (name doesn't matter), you would specify only the
membership section.

<membership defaultProvider="CustomSqlMembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="CustomSqlMembershipProvider"
connectionStringName="<connString>"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
applicationName="<appname>"
requiresUniqueEmail="false"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="5"
passwordFormat="Hashed"
enablePasswordRetrieval="false"
enablePasswordReset="true"/>
</providers>
</membership>

Here is some more info:
http://weblogs.asp.net/fmarguerie/ar...ion-files.aspx

Hope this helps,
Steve

"Blasting Cap" <go****@christian.netwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
>
I am working on a web app that I want to be able to use a separate config
file on, in addition to the web.config file that's already working in the
application.

If I put the following in the web.config file (VS 2005, Framework 2.0), I
can retrieve the values fine:

<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>

I retrieve the value with this line in the codefile in one of the apps on
the page:

Session("MyExchangeServer") =
WebConfigurationManager.AppSettings("fileInputFold er").ToString

The placement of the above appsettings line is right after the
</system.webin the web.config file, and immediately before the
<system.netline.

Any of those values can be read with no problem if they're in the
web.config file.

I added a new item to my project, app.config.

It looks like this:

<?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>
<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>
<connectionStrings/>
<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="false" />
<!--
The <authenticationsection enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrorssection 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>

</configuration>
It returns this message when I try to load the page.

The format of a configSource file must be an element containing the name
of the section. (C:\Inetpub\wwwroot\test\App.config line 10)

The only thing I have changed from the original app.config file was where
appSettings was already in the file, in the form <appSettings/>. Where you
see the <appSettingsand the 3-4 lines followed by the </appSettings>, I
simply replaced it.

The exact error on the page is:

Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.

Parser Error Message: The format of a configSource file must be an element
containing the name of the section.

Source Error:
Line 8: \Windows\Microsoft.Net\Framework\v2.x\Config
Line 9: -->
Line 10: <configuration>
Line 11: <appSettings>
Line 12: <add key="fileInputFolder" value="C:\National City
Downloads\test"/>
Source File: C:\Inetpub\wwwroot\test\App.config Line: 10
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.210
Any idea what I am doing wrong on this? I'd like to do some more with
this alternate config file, but I'm just trying to get the simple stuff to
work, before I do anything else.

Thanks,

BC

Jun 5 '07 #2
Steve -

thanks for the assistance. With your example and the link, I finally
saw what I was doing.....

Thanks!!

BC

PlatinumBay wrote:
Blasting Cap,

The use of the ConfigSource attribute is as follows:

Each section that supports configSource gets specified as
<membership configSource="config\membership.config"/>

In the membership.config (name doesn't matter), you would specify only the
membership section.

<membership defaultProvider="CustomSqlMembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="CustomSqlMembershipProvider"
connectionStringName="<connString>"
type="System.Web.Security.SqlMembershipProvider, System.Web,
Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
applicationName="<appname>"
requiresUniqueEmail="false"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
maxInvalidPasswordAttempts="5"
passwordAttemptWindow="5"
passwordFormat="Hashed"
enablePasswordRetrieval="false"
enablePasswordReset="true"/>
</providers>
</membership>

Here is some more info:
http://weblogs.asp.net/fmarguerie/ar...ion-files.aspx

Hope this helps,
Steve

"Blasting Cap" <go****@christian.netwrote in message
news:eq**************@TK2MSFTNGP03.phx.gbl...
>I am working on a web app that I want to be able to use a separate config
file on, in addition to the web.config file that's already working in the
application.

If I put the following in the web.config file (VS 2005, Framework 2.0), I
can retrieve the values fine:

<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>

I retrieve the value with this line in the codefile in one of the apps on
the page:

Session("MyExchangeServer") =
WebConfigurationManager.AppSettings("fileInputFol der").ToString

The placement of the above appsettings line is right after the
</system.webin the web.config file, and immediately before the
<system.netline.

Any of those values can be read with no problem if they're in the
web.config file.

I added a new item to my project, app.config.

It looks like this:

<?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>
<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial
Catalog=CIC_BankModel;Persist Security Info=True;User
ID=sa;Password=adminsql"/>
</appSettings>
<connectionStrings/>
<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="false" />
<!--
The <authenticationsection enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrorssection 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>

</configuration>
It returns this message when I try to load the page.

The format of a configSource file must be an element containing the name
of the section. (C:\Inetpub\wwwroot\test\App.config line 10)

The only thing I have changed from the original app.config file was where
appSettings was already in the file, in the form <appSettings/>. Where you
see the <appSettingsand the 3-4 lines followed by the </appSettings>, I
simply replaced it.

The exact error on the page is:

Configuration Error
Description: An error occurred during the processing of a configuration
file required to service this request. Please review the specific error
details below and modify your configuration file appropriately.

Parser Error Message: The format of a configSource file must be an element
containing the name of the section.

Source Error:
Line 8: \Windows\Microsoft.Net\Framework\v2.x\Config
Line 9: -->
Line 10: <configuration>
Line 11: <appSettings>
Line 12: <add key="fileInputFolder" value="C:\National City
Downloads\test"/>
Source File: C:\Inetpub\wwwroot\test\App.config Line: 10
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42;
ASP.NET Version:2.0.50727.210
Any idea what I am doing wrong on this? I'd like to do some more with
this alternate config file, but I'm just trying to get the simple stuff to
work, before I do anything else.

Thanks,

BC

Jun 5 '07 #3
re:
!I want to be able to use a separate config file on, in addition to
!the web.config file that's already working in the application.

To use a separate config file for the appsettings section of web.config, use :

<appSettings configSource="somefile.config"/>

To enable the configuration to be recognized on any change to "somefile.config",
edit machine.config, in the <configSectionssection, and edit <section name="appSettings" ... >,
adding : restartOnExternalChanges="true"

That'd make it :

<section name="appSettings" type="System.Configuration.AppSettingsSection, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="true"
requirePermission="false" />

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Blasting Cap" <go****@christian.netwrote in message news:eq**************@TK2MSFTNGP03.phx.gbl...
>
I am working on a web app that I want to be able to use a separate config file on, in addition to
the web.config file that's already working in the application.

If I put the following in the web.config file (VS 2005, Framework 2.0), I can retrieve the values
fine:

<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial Catalog=CIC_BankModel;Persist
Security Info=True;User ID=sa;Password=adminsql"/>
</appSettings>

I retrieve the value with this line in the codefile in one of the apps on the page:

Session("MyExchangeServer") = WebConfigurationManager.AppSettings("fileInputFold er").ToString

The placement of the above appsettings line is right after the </system.webin the web.config
file, and immediately before the <system.netline.

Any of those values can be read with no problem if they're in the web.config file.

I added a new item to my project, app.config.

It looks like this:

<?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>
<appSettings>
<add key="fileInputFolder" value="C:\National City Downloads\test"/>
<add key="fileTransaction" value="\Transactions\"/>
<add key="TimerInterval" value="20000"/>
<add key="Conn" value ="Data Source=dellserver\sql2000;Initial Catalog=CIC_BankModel;Persist
Security Info=True;User ID=sa;Password=adminsql"/>
</appSettings>
<connectionStrings/>
<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="false" />
<!--
The <authenticationsection enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows" />
<!--
The <customErrorssection 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>

</configuration>
It returns this message when I try to load the page.

The format of a configSource file must be an element containing the name of the section.
(C:\Inetpub\wwwroot\test\App.config line 10)

The only thing I have changed from the original app.config file was where appSettings was already
in the file, in the form <appSettings/>. Where you see the <appSettingsand the 3-4 lines
followed by the </appSettings>, I simply replaced it.

The exact error on the page is:

Configuration Error
Description: An error occurred during the processing of a configuration file required to service
this request. Please review the specific error details below and modify your configuration file
appropriately.

Parser Error Message: The format of a configSource file must be an element containing the name of
the section.

Source Error:
Line 8: \Windows\Microsoft.Net\Framework\v2.x\Config
Line 9: -->
Line 10: <configuration>
Line 11: <appSettings>
Line 12: <add key="fileInputFolder" value="C:\National City Downloads\test"/>
Source File: C:\Inetpub\wwwroot\test\App.config Line: 10
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210
Any idea what I am doing wrong on this? I'd like to do some more with this alternate config file,
but I'm just trying to get the simple stuff to work, before I do anything else.

Thanks,

BC


Jun 5 '07 #4

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

Similar topics

13
by: Maxim Khesin | last post by:
I want to have a config file with my python proggie, satisfying the following requirements: 1) support key->(value, default) 2) simple and intuitive to read and edit 3) easyly readable into a...
4
by: Fuzzyman | last post by:
There have been a couple of config file 'systems' announced recently, that focus on building more powerful and complex configuration files. ConfigObj is a module to enable you to much more *simply*...
2
by: Burt Lewis | last post by:
Hi, I have 2 xsl style sheets calling separate rss feeds and I use ASP to display. Problem is that the 1st xsl takes on the style of the 2nd xsl even though they are different formats. I...
1
by: Klas Mellbourn | last post by:
I have several assemblies, in separate dll:s, each with nunit tests embedded. Every assembly requires its own config file. I would like to run all nunit tests on the same command line. Like this: ...
2
by: Suresh Gladstone | last post by:
Hi, This is a bit with versioning and installation of the .NET dlls. I want to perform the following, 1. A third party application will be invoking my .NET dll through COM interop . For this I...
4
by: grs | last post by:
Can a class library have a app.config file. Reason for asking is that the microsoft application blocks all read from myApp.exe.config. How can you use the application blocks if you do not have an...
5
by: benliu | last post by:
i have a visual studio website that i am integrating with community server, a third party software for creating communities. To paraphrase, i am trying to have users that log in to my site...
12
by: dbuchanan | last post by:
Hello, (Is this the proper newsgroup?) === Background === I am building a solution with two projects. One project is my data access layer which contains my DataSet as an xsd file. The XSD...
5
by: mmcd79 | last post by:
I built a VB.net application that makes use of a machine level DB connection string setting, and a user level starting location setting. The machine level setting and the default user based...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.