本文整理汇总了C#中Microsoft.Web.Administration类的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Web.Administration类的具体用法?C# Microsoft.Web.Administration怎么用?C# Microsoft.Web.Administration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Microsoft.Web.Administration类属于命名空间,在下文中一共展示了Microsoft.Web.Administration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSiteUrl
private static string GetSiteUrl(IIS.Site site)
{
var urls = GetSiteUrls(site);
if (urls == null)
{
return null;
}
else
{
return urls.FirstOrDefault();
}
}
示例2: InvalidOperationException
private static async Task WaitForState(Func<IIS.ObjectState> getState, IIS.ObjectState state)
{
TimeSpan totalWait = TimeSpan.Zero;
IIS.ObjectState? currentState;
while ((currentState = SafeGetState(getState)) != state)
{
totalWait += _waitInterval;
if (totalWait > _maxWaitInterval)
{
throw new InvalidOperationException(String.Format("State unchanged after {0} seconds. Expected state: '{1}', actual state: '{2}'.",
totalWait.TotalSeconds, state, currentState));
}
await Task.Delay(_waitInterval);
}
}
示例3: Site
internal Site(IIS.Site iisSite, bool isCurrentSite)
{
Name = iisSite.Name;
Urls = iisSite.Bindings
.Select(b => new UriBuilder
{
Host = string.IsNullOrEmpty(b.Host) ? "localhost" : b.Host,
Scheme = b.Protocol,
Port = b.EndPoint.Port == 80 ? -1 : b.EndPoint.Port
}.Uri);
if (new[] { IIS.ObjectState.Started, IIS.ObjectState.Starting }.Any(os => os == iisSite.State))
State = SiteState.Started;
IsCurrentSite = isCurrentSite;
}
示例4: GetSiteUrl
private string GetSiteUrl(IIS.Site site)
{
if (site == null)
{
return null;
}
IIS.Binding binding = site.Bindings.Last();
var builder = new UriBuilder
{
Host = String.IsNullOrEmpty(binding.Host) ? "localhost" : binding.Host,
Scheme = binding.Protocol,
Port = binding.EndPoint.Port
};
if (builder.Port == 80)
{
builder.Port = -1;
}
return builder.ToString();
}
示例5: GetSiteUrls
private static List<string> GetSiteUrls(IIS.Site site)
{
var urls = new List<string>();
if (site == null)
{
return null;
}
foreach (IIS.Binding binding in site.Bindings)
{
var builder = new UriBuilder
{
Host = String.IsNullOrEmpty(binding.Host) ? "localhost" : binding.Host,
Scheme = binding.Protocol,
Port = binding.EndPoint.Port == 80 ? -1 : binding.EndPoint.Port
};
urls.Add(builder.ToString());
}
return urls;
}
示例6: EnsureDefaultDocument
private static void EnsureDefaultDocument(IIS.ServerManager iis)
{
Configuration applicationHostConfiguration = iis.GetApplicationHostConfiguration();
ConfigurationSection defaultDocumentSection = applicationHostConfiguration.GetSection("system.webServer/defaultDocument");
ConfigurationElementCollection filesCollection = defaultDocumentSection.GetCollection("files");
if (!filesCollection.Any(ConfigurationElementContainsHostingStart))
{
ConfigurationElement addElement = filesCollection.CreateElement("add");
addElement["value"] = HostingStartHtml;
filesCollection.Add(addElement);
iis.CommitChanges();
}
}
示例7: CreateSite
private IIS.Site CreateSite(IIS.ServerManager iis, string applicationName, string siteName, string siteRoot, List<string> siteBindings)
{
var pool = EnsureAppPool(iis, applicationName);
EnsureDefaultDocument(iis);
IIS.Site site;
if (siteBindings != null && siteBindings.Count > 0)
{
site = iis.Sites.Add(siteName, "http", siteBindings.First(), siteRoot);
}
else
{
int sitePort = GetRandomPort(iis);
site = iis.Sites.Add(siteName, siteRoot, sitePort);
}
site.ApplicationDefaults.ApplicationPoolName = pool.Name;
if (_traceFailedRequests)
{
site.TraceFailedRequestsLogging.Enabled = true;
string path = Path.Combine(_logPath, applicationName, "Logs");
Directory.CreateDirectory(path);
site.TraceFailedRequestsLogging.Directory = path;
}
return site;
}
示例8: WaitForState
public static void WaitForState(this IIS.ApplicationPool appPool, IIS.ObjectState state)
{
new PollingWait(() => { }, () => appPool.State == state).Invoke();
}
示例9: NoHostNameFoundException
private static IIS.Binding EnsureBinding(IIS.BindingCollection siteBindings)
{
if (siteBindings == null)
{
throw new NoHostNameFoundException();
}
IIS.Binding iisBinding = siteBindings.FirstOrDefault();
if (iisBinding == null)
{
throw new NoHostNameFoundException();
}
return iisBinding;
}
示例10: GetRandomPort
private int GetRandomPort(IIS.ServerManager iis)
{
int randomPort = portNumberGenRnd.Next(1025, 65535);
while (!IsAvailable(randomPort, iis))
{
randomPort = portNumberGenRnd.Next(1025, 65535);
}
return randomPort;
}
示例11: ConfigurationElementContainsHostingStart
private static bool ConfigurationElementContainsHostingStart(IIS.ConfigurationElement configurationElement)
{
object valueAttribute = configurationElement["value"];
return valueAttribute != null && String.Equals(HostingStartHtml, valueAttribute.ToString(), StringComparison.OrdinalIgnoreCase);
}
示例12: IsAvailable
private static bool IsAvailable(string host, int port, IIS.ServerManager iis)
{
foreach (var iisSite in iis.Sites)
{
foreach (var binding in iisSite.Bindings)
{
if (binding.EndPoint != null && binding.EndPoint.Port == port && binding.Host == host)
{
return false;
}
}
}
return true;
}
示例13: DeleteSite
private void DeleteSite(IIS.ServerManager iis, string siteName, bool deletePhysicalFiles = true)
{
var site = iis.Sites[siteName];
if (site != null)
{
site.StopAndWait();
if (deletePhysicalFiles)
{
string physicalPath = site.Applications[0].VirtualDirectories[0].PhysicalPath;
DeleteSafe(physicalPath);
}
iis.Sites.Remove(site);
}
}
示例14: EnsureAppPool
private static IIS.ApplicationPool EnsureAppPool(IIS.ServerManager iis)
{
var kuduAppPool = iis.ApplicationPools["kudu"];
if (kuduAppPool == null) {
iis.ApplicationPools.Add("kudu");
iis.CommitChanges();
kuduAppPool = iis.ApplicationPools["kudu"];
kuduAppPool.Enable32BitAppOnWin64 = true;
kuduAppPool.ManagedPipelineMode = IIS.ManagedPipelineMode.Integrated;
kuduAppPool.ManagedRuntimeVersion = "v4.0";
kuduAppPool.AutoStart = true;
}
return kuduAppPool;
}
示例15: EnsureAppPool
private static IIS.ApplicationPool EnsureAppPool(IIS.ServerManager iis, string appName)
{
string appPoolName = GetAppPool(appName);
var kuduAppPool = iis.ApplicationPools[appPoolName];
if (kuduAppPool == null)
{
iis.ApplicationPools.Add(appPoolName);
iis.CommitChanges();
kuduAppPool = iis.ApplicationPools[appPoolName];
kuduAppPool.ManagedPipelineMode = IIS.ManagedPipelineMode.Integrated;
kuduAppPool.ManagedRuntimeVersion = "v4.0";
kuduAppPool.AutoStart = true;
kuduAppPool.ProcessModel.LoadUserProfile = true;
}
EnsureDefaultDocument(iis);
return kuduAppPool;
}