How can I restart IIS or server from ASPX page or web service?

D

DataSprings

Hi. I am wondering if its possible to restart IIS or my web server
simply from an IIS page? Not sure what code I would need and maybe
impersonation? Any thoughts or ideas anyone?

-Chad
 
G

Guest

Doing IISRESET is a bit heavy-duty, I'd think. Why not start out by just
recycling the ASPNET Worker process:

private void KillAspNetProcess()
{
string processName = "aspnet_wp";
System.OperatingSystem os = System.Environment.OSVersion;

//Longhorn and Windows Server 2003 use w3wp.exe
if((os.Version.Major == 5 && os.Version.Minor > 1) || os.Version.Major ==6)
processName = "w3wp";

foreach(Process process in Process.GetProcessesByName(processName))
{
Response.Write("Killing ASP.NET worker process (Process ID:" +
process.Id + ")");
process.Kill();
}
}
 

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

Top