internal void BuildIisInformation(HtmlGenericControl main) { if (this.settings.UseIisBindings) { // Adds header HtmlGenericControl gc = this.rcb.AddHeader(main, "IIS Information"); try { foreach (string name in IisHelper.GetSitesNames()) { this.rcb.AddTabHeader(gc, "Web site: " + name); this.rcb.AddSectionHeader(gc, "General information"); Dictionary <string, string> values = IisHelper.GetSiteInfo(name); this.rcb.AddTable(gc, new string[] { "Key", "Value" }, values); this.rcb.AddSectionHeader(gc, "Bindings information"); this.rcb.AddTable(gc, IisHelper.GetSiteBindings(name)); } } catch (Exception error) { this.rcb.AddSingleLineOfText(gc, error.Message); } } }
/// <summary> /// Keeps the IIS application pool alive. /// </summary> private void KeepIisAlive() { try { if (!IisHelper.IsHostedByIis) { return; } if (_ping != null && _ping.Execute()) { return; } IEnumerable <Uri> uris = IisHelper.GetUris(); foreach (Uri uri in uris) { Ping ping = new Ping(uri); if (ping.Execute()) { _ping = ping; break; } } } catch (Exception ex) { Log.Error(ex); } }
internal void BuildApplicationPoolsInformation(HtmlGenericControl main) { if (this.settings.UseIisAppPools) { // Adds header HtmlGenericControl gc = this.rcb.AddHeader(main, "IIS Application Pools Information"); try { this.rcb.AddTable(gc, IisHelper.GetApplicationPools()); } catch (Exception error) { this.rcb.AddSingleLineOfText(gc, error.Message); } } }
/// <summary> /// Processes the input parameters. /// </summary> /// <param name="args"></param> private static void ProcessInput(IList <string> args) { if (args == null || !args.Any()) { throw new ConfigurationException("No input parameters were specified."); } IDictionary <string, string> param = args .Where(x => x.Contains("=")) .Select(arg => arg.Split('=')) .ToDictionary(x => x[0].Replace("-", string.Empty).ToLower(), x => x[1]); SiteInformation siteInformation = SiteInformation.CreateFromParams(param); switch (args[0]) { case "-AssignCertificateToSite": IisHelper.AssignCertificateToSite(siteInformation); break; case "-UnassignCertificateFromSite": IisHelper.UnassignCertificateFromSite(siteInformation); break; case "-InstallNetTcpPortSharingConfig": NetTcpPortSharing.InstallNetTcpPortSharingConfig(param["path"]); break; case "-UninstallNetTcpPortSharingConfig": NetTcpPortSharing.UninstallNetTcpPortSharingConfig(); break; default: throw new ConfigurationException("Could not determine action based on input parameters."); } }
private void BindPage() { IisHelper.GetSites(); }
// // Internal // // Transform the ASP+ Request and Response Structures in // Channel Structures: // ** Request.ServerVariables // ** Request.InputStream // ** Response.Headers // // This is needed to reduce the between dependency COR Channels // and ASP+ // private void InternalProcessRequest(HttpContext context) { try { HttpRequest httpRequest = context.Request; // check if have previously loaded configuration if (!bLoadedConfiguration) { // locking a random static variable, so we can lock the class lock (HttpRemotingHandler.ApplicationConfigurationFile) { if (!bLoadedConfiguration) { // Initialize IIS information IisHelper.Initialize(); // set application name if (RemotingConfiguration.ApplicationName == null) { RemotingConfiguration.ApplicationName = httpRequest.ApplicationPath; } String filename = String.Concat(httpRequest.PhysicalApplicationPath, ApplicationConfigurationFile); if (File.Exists(filename)) { try { RemotingConfiguration.Configure(filename, false /*enableSecurity*/); } catch (Exception e) { s_fatalException = e; WriteException(context, e); return; } } try { // do a search for a registered channel that wants to listen IChannelReceiverHook httpChannel = null; IChannel[] channels = ChannelServices.RegisteredChannels; foreach (IChannel channel in channels) { IChannelReceiverHook hook = channel as IChannelReceiverHook; if (hook != null) { if (String.Compare(hook.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0) { if (hook.WantsToListen) { httpChannel = hook; break; } } } } if (httpChannel == null) { // No http channel that was listening found. // Create a new channel. HttpChannel newHttpChannel = new HttpChannel(); ChannelServices.RegisterChannel(newHttpChannel, false /*enableSecurity*/); httpChannel = newHttpChannel; } String scheme = null; if (IisHelper.IsSslRequired) { scheme = "https"; } else { scheme = "http"; } String hookChannelUri = scheme + "://" + CoreChannel.GetMachineIp(); int port = context.Request.Url.Port; String restOfUri = ":" + port + "/" + RemotingConfiguration.ApplicationName; hookChannelUri += restOfUri; // add hook uri for this channel httpChannel.AddHookChannelUri(hookChannelUri); // If it uses ChannelDataStore, re-retrieve updated url in case it was updated. ChannelDataStore cds = ((IChannelReceiver)httpChannel).ChannelData as ChannelDataStore; if (cds != null) { hookChannelUri = cds.ChannelUris[0]; } IisHelper.ApplicationUrl = hookChannelUri; // This is a hack to refresh the channel data. // In V-Next, we will add a ChannelServices.RefreshChannelData() api. ChannelServices.UnregisterChannel(null); s_transportSink = new HttpHandlerTransportSink(httpChannel.ChannelSinkChain); } catch (Exception e) { s_fatalException = e; WriteException(context, e); return; } bLoadedConfiguration = true; } } } if (s_fatalException == null) { if (!CanServiceRequest(context)) { WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished"))); } else { s_transportSink.HandleRequest(context); } } else { WriteException(context, s_fatalException); } } catch (Exception e) { WriteException(context, e); } } // InternalProcessRequest
private void InternalProcessRequest(HttpContext context) { try { HttpRequest request = context.Request; if (!bLoadedConfiguration) { lock (ApplicationConfigurationFile) { if (!bLoadedConfiguration) { IisHelper.Initialize(); if (RemotingConfiguration.ApplicationName == null) { RemotingConfiguration.ApplicationName = request.ApplicationPath; } string path = request.PhysicalApplicationPath + ApplicationConfigurationFile; if (File.Exists(path)) { try { RemotingConfiguration.Configure(path, false); } catch (Exception exception) { s_fatalException = exception; this.WriteException(context, exception); return; } } try { IChannelReceiverHook hook = null; foreach (IChannel channel in ChannelServices.RegisteredChannels) { IChannelReceiverHook hook2 = channel as IChannelReceiverHook; if (((hook2 != null) && (string.Compare(hook2.ChannelScheme, "http", StringComparison.OrdinalIgnoreCase) == 0)) && hook2.WantsToListen) { hook = hook2; break; } } if (hook == null) { HttpChannel chnl = new HttpChannel(); ChannelServices.RegisterChannel(chnl, false); hook = chnl; } string str2 = null; if (IisHelper.IsSslRequired) { str2 = "https"; } else { str2 = "http"; } string channelUri = str2 + "://" + CoreChannel.GetMachineIp(); int port = context.Request.Url.Port; string str4 = string.Concat(new object[] { ":", port, "/", RemotingConfiguration.ApplicationName }); channelUri = channelUri + str4; hook.AddHookChannelUri(channelUri); ChannelDataStore channelData = ((IChannelReceiver)hook).ChannelData as ChannelDataStore; if (channelData != null) { channelUri = channelData.ChannelUris[0]; } IisHelper.ApplicationUrl = channelUri; ChannelServices.UnregisterChannel(null); s_transportSink = new HttpHandlerTransportSink(hook.ChannelSinkChain); } catch (Exception exception2) { s_fatalException = exception2; this.WriteException(context, exception2); return; } bLoadedConfiguration = true; } } } if (s_fatalException == null) { if (!this.CanServiceRequest(context)) { this.WriteException(context, new RemotingException(CoreChannel.GetResourceString("Remoting_ChnlSink_UriNotPublished"))); } else { s_transportSink.HandleRequest(context); } } else { this.WriteException(context, s_fatalException); } } catch (Exception exception3) { this.WriteException(context, exception3); } }