Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Separate .config file

Reply
Thread Tools

Separate .config file

 
 
Blasting Cap
Guest
Posts: n/a
 
      06-05-2007

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.web> in the web.config file, and immediately before the
<system.net> line.

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 <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>

</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 <appSettings> and 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
 
Reply With Quote
 
 
 
 
PlatinumBay
Guest
Posts: n/a
 
      06-05-2007
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" <> wrote in message
news:...
>
> 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.web> in the web.config file, and immediately before the
> <system.net> line.
>
> 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 <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>
>
> </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 <appSettings> and 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



 
Reply With Quote
 
 
 
 
Blasting Cap
Guest
Posts: n/a
 
      06-05-2007
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" <> wrote in message
> news:...
>> 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.web> in the web.config file, and immediately before the
>> <system.net> line.
>>
>> 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 <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>
>>
>> </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 <appSettings> and 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

>
>

 
Reply With Quote
 
Juan T. Llibre
Guest
Posts: n/a
 
      06-05-2007
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 <configSections> section, 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" <> wrote in message news:...
>
> 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.web> in the web.config
> file, and immediately before the <system.net> line.
>
> 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 <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>
>
> </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 <appSettings> and 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




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to redirect both std out and err to a file together and still err to a separate file qwertmonkey@syberianoutpost.ru Java 1 08-29-2012 12:10 AM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:27 AM
Separate Tabs, Separate Sessions BigAndy Firefox 0 05-09-2007 09:26 AM
Using separate classpaths for separate classes? Frank Fredstone Java 1 06-27-2006 06:46 AM
How to use several separate classes (separate files) to be executed in one class (another file) EvgueniB Java 1 12-15-2003 01:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57