ASP.NET + WindowsServices

A

Andy

Hello,

I would like to access to Windows Service via ASP.NET. I have written
very simple web application which starts and stops windows service. Here
is my StarButton event:

private void StartButton_Click(object sender, System.EventArgs e)
{
ServiceController sc = new ServiceController();
sc.ServiceName = "MyService";
sc.Start();
}

When I try to start Windows Service I receive the following error:
System.ComponentModel.Win32Exception: Access is denied.

How to set up my web application or my Windows Service to have a
perrmission to stoping or starting Windows Service via ASP.NET. I'm
newbie in Windows Services and I would ask You for help.
Thank You in advance.

Andy
 
G

George

1. The account ASP.NET runs under needs permissions to start/stop the service. Just add it to Admin group.
2. did you write the service "MyService" itself?
3. Why do you need to start/stop service from ASP.NET. The service usually starts automatically when windows starts.


George

Hello,

I would like to access to Windows Service via ASP.NET. I have written
very simple web application which starts and stops windows service. Here
is my StarButton event:

private void StartButton_Click(object sender, System.EventArgs e)
{
ServiceController sc = new ServiceController();
sc.ServiceName = "MyService";
sc.Start();
}

When I try to start Windows Service I receive the following error:
System.ComponentModel.Win32Exception: Access is denied.

How to set up my web application or my Windows Service to have a
perrmission to stoping or starting Windows Service via ASP.NET. I'm
newbie in Windows Services and I would ask You for help.
Thank You in advance.

Andy
 
A

Andy

George said:
1. The account ASP.NET runs under needs permissions to start/stop the
service. Just add it to Admin group.
2. did you write the service "MyService" itself? Yes.

3. Why do you need to start/stop service from ASP.NET. The service
usually starts automatically when windows starts.
I will write in the future the specific web application that will
controll one of the windows services
 
A

Andy

George said:
1. The account ASP.NET runs under needs permissions to start/stop the
service. Just add it to Admin group.

There isn't the other solution ? I don't want that ASPNET runs under
Admin permission. It may be dengerous.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top