问题
So Let me tell you that I am developing a IIS monitoring Website in MVC 5
I try to stop an application within C# code but it always throw exception. mentioned in the title.
I am using code:
ServerManager manager = new ServerManager(@"C:\Windows\System32\inetsrv\config\applicationHost.config");
foreach (Site site in manager.Sites)
{
site.Stop();
}
The exception is:
{"The method or operation is not implemented."}
at Microsoft.Web.Administration.Interop.IAppHostMethodInstance.Execute()
at Microsoft.Web.Administration.ConfigurationMethodInstance.Execute()
at Microsoft.Web.Administration.ConfigurationElement.ExecuteMethod(String methodName)
at Microsoft.Web.Administration.Site.Stop()
at WebsiteReplication.Repository.IISConfiguration.VerifyWebsites(List`1 websitesDirs) in e:\RLTSquare\MetisSilverlight\Code\WebsiteReplication\WebsiteReplication\Repository\IISConfiguration.cs:line 67
What I have read uptil now that I need to run my website under administrator privilages. I did that also, I also tried to add manifest file and than changing the access level by this line of code
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Nothing is not working. As I cannot add this manifest file to MVC application because the combobox under properties of the project does not show menifest file there.
I want to list all websites from IIS server in my MVC application. Also I need to stop/start website from my MVC application.
回答1:
So, after alot of R&D i am able to answer my own question. I just changed the app pool rights from AppPoolIdentity to LocalSystem and everything was fine.
来源:https://stackoverflow.com/questions/39349157/the-method-or-operation-is-not-implemented-while-stopping-iis-website-in-c-shar