B
Blasting Cap
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("fileInputFolder").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
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("fileInputFolder").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