Reputation: 21
I'm creating a .NET Core 2.1 Web API project (with Angular 7 front-end) where I'm using the Microsoft.Web.Administration API to pull information from remote IIS web servers (mainly listing websites, applications, app-pools, etc.):
https://learn.microsoft.com/en-us/dotnet/api/microsoft.web.administration?view=iis-dotnet
As a quick note, here is how I am instantiating a remote-IIS server object, a ServerManager
object:
To create the ServerManager
object (the IIS 'container' object, so-to-speak) I use one of the hidden constructors where I pass the remote IIS server's applicationHost.config
file path to it (located at C:\Windows\System32\inetsrv\config
-- default location). I'm doing this because I receive COM-related issues when I use the ServerManager.OpenRemote(string server_ip)
method.
Anyways, whenever I'm trying to use the ServerManager's, Site's, and Application's GetWebConfiguration
methods to get the Web.config
files for each IIS object, each of the aforementioned object's GetWebConfig
methods fail. The app doesn't crash when I run my code, but upon object inspection in the debugger, this is the following error listed:
my_siteWebConfig.RootSectionGroup = 'my_siteWebConfig.RootSectionGroup' threw an exception of type 'System.IO.DirectoryNotFoundException'
It looks like the GetWebConfiguration
code is looking for the site/application's web.config
file in an non-existent directory. Debugger shows that the ConfigurationPathToEdit
equals "MACHINE/WEBROOT/APPHOST/my_site"
. It's looking in the directory where the applicationHost.Config
file is (the global IIS settings file location). However, my websites' & applications' web.config
files are stored under the D:\ drive
at D:\MyCompany
. Is there a way for the GetWebConfiguration
methods to look at a directory other than the default applicationHost.Config
directory for the config files?
Sorry if this is a bit confusing. Thanks for any help, and let me know if something isn't clear. Thank you.
Upvotes: 2
Views: 533