如何通过c#代码访问远程IIS服务器。 [英] How do I access remote IIS server by c# code.

查看:490
本文介绍了如何通过c#代码访问远程IIS服务器。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<预类= "x_x_notranslate" ID = "x_x_pre816098" 风格="背景色:#fbedbb;填充:6像素;字体大小:9pt的;行高:正常;字体家庭:索拉,"信使新',Courier,mono; white-space:pre-wrap; border:1px solid rgb(251,237,187);自动换行:break-word; word-break:break-word">如何 do 我通过c#代码访问远程IIS服务器。
喜欢 我是 in 我的本地机器,我登录到我的远程服务器机器ABC001 其中我的.net应用程序已部署

现在如何 do 我访问IIS( ABC001)<跨度类= "x_x_code-sdkkeyword" 样式= "余量:0像素;填充:0像素;边界:0像素;颜色:#339999">从我的本地机器,并通过C#代码开始/停止IIS。

解决方案

您可以使用System.ServiceProcess.ServiceController类来执行此操作。 您创建一个ServiceController,使用与您在"net start"中使用的名称相同的名称连接到远程计算机上的IIS服务。和"网络停止"。 
该对象具有Start和Stop方法。


How do I access remote IIS server by c# code.
Like in I am in my local machine and I login to my remote server machine ABC001 where my .net application is deployed.

Now how do I access that IIS(ABC001) from my local machine and Start/Stop the IIS through C# code.

解决方案

You can use the System.ServiceProcess.ServiceController class to do that.  You create a ServiceController that connects to the IIS service on your remote machine, using the same name that you'd use in "net start" and "net stop".  That object has Start and Stop methods.


这篇关于如何通过c#代码访问远程IIS服务器。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆