Search code examples
c#asp.netmonoappsettingsmod-mono

Mod_Mono doesn't load Web.Config AppSettings from configSource


I don't understand why Mono isn't loading appSettings from an external file. I've seen others' posts detailing how they've achieved this in .NET and Mono. However, I'm only able to get it working in .NET.

I've tried the configSource and file attributes of appSettings. The only way the appSettings seem to load is to move them into the main config file.

Here is the code I currently have.

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <appSettings configSource="data\app.config" />
    ...
</configuration>

app.config

<appSettings>
    <add key="AdminIcon" value="96d6f2e7e1f705ab5e59c84a6dc009b2.png" />
    <add key="MailPort" value="25" />
    <add key="GAEnable" value="False" />
    ...
</appSettings>

Reading Settings for Code-Behind

using System.Web.Configuration;

string adminIcon = WebConfigurationManager.AppSettings["AdminIcon"].Value;

Solution

  • My web server is running Ubuntu. In order to fix the issue outlined above, I needed to change the path delimiter from \ to /.

    <!--<appSettings configSource="data\app.config" />-->
    <appSettings configSource="data/app.config" />
    

    This is all find and dandy, but this will now break .NET on Windows. This is likely a system dependent issue and not specifically bound to Mono or .NET.