IT:AD:NConfig:HowTo:Configure within WebSites
Summary
NConfig is a little more strict in web apps.
Process
For one, you can't ../../ yourself out the top of the website (so you can't share one file between front/back servers)
But that's actually good practice (you don't want the back server's connection string to be shared out in the front server, do you?)
Secondly your machineName.app.config file must not be Added to the project. Again, that's a good thing. You don't want your dev config files to end up on the production servers.
Thirdly…if your site is within a VDir, append the VDir to the front of the path:
//If the VDir is BackNSI, then:
string[] possiblePaths = new string[]
{
"BackNSI\\Config\\MachineSpecificSettings\\app.config",
};
try
{
NConfigurator.UsingFiles(possiblePaths).SetAsSystemDefault();
}
catch (System.Exception e)
{
ITracingService tracingService = XAct.Shortcuts.ServiceLocate<ITracingService>();
tracingService.TraceException(TraceLevel.Error, e,"Could not handle NConfig references.");
}
string check = System.Configuration.ConfigurationManager.AppSettings["NConfig"];