[英]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 因此,让我告诉您,我正在MVC 5中开发IIS监视网站
I try to stop an application within C# code but it always throw exception. 我尝试在C#代码中停止应用程序,但始终会引发异常。 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. 由于无法将清单文件添加到MVC应用程序中,因为项目属性下的组合框未在其中显示清单文件。
I want to list all websites from IIS server in my MVC application. 我想在我的MVC应用程序中列出IIS服务器中的所有网站。 Also I need to stop/start website from my MVC application. 另外,我需要从MVC应用程序停止/启动网站。
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. 我只是将应用程序池的权限从AppPoolIdentity更改为LocalSystem ,一切都很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.