如何在asp.net中停止并启动自己的服务? [英] How to stop and start own service in asp.net ?

查看:162
本文介绍了如何在asp.net中停止并启动自己的服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我创建了一个网页,我有2个按钮,一个用于启动服务,另一个用于停止服务。



我已经根据以下步骤使用utillservice创建一个服务并安装在我的cumputer中 http: //msdn.microsoft.com/en-us/library/sd8zc8ha%28v=vs.110%29.aspx [ ^ ]



安装成功并运行serice,如果我手动停止/开始服务它的工作,我的意思是我可以停止服务它停止并启动服务它启动服务和功能工作正常。



但是如果我试图停止网页服务它不能停止服务,它显示错误,无法在计算机上打开zzz服务,

这里我附上截图也请看这个链接http://prntscr.com/5q7puj [ ^ ]



注意:我收到正确的服务名称在myController中使用ServiceControllerStatus,如果有条件,它进入内部代码执行时



Hi I am create one web page in that i have 2 buttons,one for start service and another for stop service.

I am already create one service and install in my cumputer using utillservice based on this steps http://msdn.microsoft.com/en-us/library/sd8zc8ha%28v=vs.110%29.aspx[^]

It install successfully and run serice,if i manually stop/start service it work,i mean i can stop service it stopped and start service it started service and functionality work fine.

But if i try to stop service for web page it cant stop service,it show error, "Cannot open zzz Service service on computer",
here i attach screenshot also pls look this link http://prntscr.com/5q7puj[^]

Note : i am getting correct serivce name in mycontroller using ServiceControllerStatus and it go inside if condition,when code execute

myController.Stop()





显示错误,这有什么问题?



和我们有另一个服务和另一个Web应用程序一样,可以成功停止/启动服务表单Web应用程序,我在新的Web应用程序中做了相同的工作Web应用程序,例如根文件夹,应用程序和已安装服务的每个权限文件夹。



请尽快回复



问候



Aravind



it show error,what problem with this ?

And same like we have another service and another web application,in that can successfully stop/start service form web application,i did same working web application in new web application like every permission for root folder,Application and installed service folder.

Pls reply asap

Regards

Aravind

推荐答案

这可能是与部分信任相关的问题,网页可能在没有完全访问权限的帐户下运行运行服务的系统。为了测试这一点,请在windows exe中添加servicecontroller代码并在计算机上进行部署。运行exe并查看它是否停止服务。如果确实如此,则部分信任问题需要通过在可以启动或停止服务的帐户下运行应用程序的AppPool来解决。 (我假设您使用的是IIS 7或更高版本)此应用程序。)



HTH
This may be an issue related to Partial trust, the web-page may be running under an account that doesn't have full access to the system where the service is running. In order to test this, please add the servicecontroller code in a windows exe and deploy on the machine. Run the exe and see if it stops the services. If it does then it is a problem of Partial trust which needs to sorted out by running the AppPool of the application under an account which can start or stop the service. (I am assuming that you are using IIS 7 or above) for this application).

HTH


这篇关于如何在asp.net中停止并启动自己的服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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