简体   繁体   中英

The method or operation is not implemented. while stopping IIS website in C#

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM