This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ChangeSiteBinding(string siteName, string oldBindingValue, string newBindingValue, string protocol) | |
{ | |
using (ServerManager manager = new ServerManager()) | |
{ | |
// Find the site by name from IIS | |
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name == siteName).FirstOrDefault(); | |
if (site == null) | |
{ | |
throw new Exception("The specified site name does not exist in IIS!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string GetSiteContent(string url) | |
{ | |
// Create the web request for the url passed to the method | |
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url); | |
// For the sake of this example, we'll be using the GET method. | |
// For other options, please see http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.method.aspx | |
myRequest.Method = "GET"; | |
// Get the response and store it in a WebResponse object |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void StartSite(string siteName) | |
{ | |
using (ServerManager manager = new ServerManager()) | |
{ | |
// Get the Site object | |
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name.Equals(siteName)).FirstOrDefault(); | |
// If the site does not exist, throw an exception | |
if (site == null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void StopSite(string siteName) | |
{ | |
using (ServerManager manager = new ServerManager()) | |
{ | |
// Get the Site object | |
Microsoft.Web.Administration.Site site = manager.Sites.Where(q => q.Name.Equals(siteName)).FirstOrDefault(); | |
// If the site does not exist, throw an exception | |
if (site == null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RunProcess(string path) | |
{ | |
using (Process process = new Process()) | |
{ | |
// This sets up the output redirection | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
// Specify the path to the file here | |
process.StartInfo.FileName = path; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void RunProcess(string path) | |
{ | |
using (Process process = new Process()) | |
{ | |
// This sets up the output redirection | |
process.StartInfo.UseShellExecute = false; | |
process.StartInfo.RedirectStandardOutput = true; | |
// Specify the path to the file here | |
process.StartInfo.FileName = path; |