Is it actually possible to programmatically manage the state of an FTP server in IIS7?
I'm able to manage FTP sites via the IIS manager, however, all attempts so far to manage the state of FTP sites using other means have failed, including:
- Using the IIS7 API (Microsoft.Web.Administration)
- Using WMI (with IIS6 compatibility enabled)
- Using the AppCmd tool in System32\inetsrv
Related questions:
- Why am I unable to 开发者_StackOverflow中文版get Site.State for an FTP site, when using Microsoft.Web.Administration?
Are there any workarounds I haven't tried? My objective is to manage (start/stop/query the state of) the FTP sites with C# code (as you can see from the 3 above attempted workarounds).
When querying the FTP server state using WMI, it returns code 4, which means "Stopped", even though the site is definitely shown as running in IIS manager.
AppCmd is useless, as it returns "Unknown" for FTP sites:
c:\Windows\System32\inetsrv>appcmd list site
SITE "Default Web Site" (id:1,bindings:http/*:80:,state:Stopped)
SITE "Default FTP Site" (id:2,bindings:ftp/*:21:,state:Unknown)
My workaround for managing the state is to set ServerAutoStart to false, and restart the ftpsvc Windows service. Thus far I have not found a way of detecting the state of a specific FTP server (IIS can have multiple FTP servers with different bindings).
To determine the state, you could just make a connection attempt.
To manage the state, I don't have any suggestions, I would've put my chips on WMI.
精彩评论