Ermittelt die Id über den Namen der WebSite.
Diese Id findet sich z.B. wieder im Verzeichnisnamen für die IIS LogFiles. Außerdem wird sie benötigt, um manche Einstellungen programmatisch zu ändern.
/// <summary>
/// Get website id on <paramref name="websiteName"/>
/// </summary>
/// <param name = "websiteName">Name of the website e.g. test</param>
/// <returns>
/// Less the 0, site does not exist
/// Id of the existing site
/// </returns>
public long GetWebSiteId(string websiteName)
{
long result = -1;
using (var serverManager = new ServerManager())
{
var site = serverManager.Sites.FirstOrDefault(s => s.Name == websiteName);
if (site != null)
result = site.Id;
}
return (result);
}
Kommentare zum Snippet