How to OpenWebConfiguration with physical path?

You will have to map the physicalPath to a virtualPath. Here is how you would do that.

using System.Web.Configuration;  //Reference the System.Web DLL (project needs to be using .Net 4.0 full, not client framework)

public static Configuration OpenConfigFile(string configPath)
{
    var configFile = new FileInfo(configPath);
    var vdm = new VirtualDirectoryMapping(configFile.DirectoryName, true, configFile.Name);
    var wcfm = new WebConfigurationFileMap();
    wcfm.VirtualDirectories.Add("https://stackoverflow.com/", vdm);
    return WebConfigurationManager.OpenMappedWebConfiguration(wcfm, "https://stackoverflow.com/");
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)