473,245 Members | 1,755 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,245 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 10547
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.