static void VerifyIisDetected(HttpContext context) { TryInitializeHosting(); if (Iis == null) { lock (_syncRoot) { if (Iis == null) { if (context == null) { throw new InvalidOperationException(); } Iis iisVersion = null; string serverSoftwareHeader = context.Request.ServerVariables[SERVER_SOFTWARE_KEY]; int slashPos = serverSoftwareHeader != null?serverSoftwareHeader.IndexOf('/') : -1; if (slashPos != -1) { string productName = serverSoftwareHeader.Substring(0, slashPos); Version parsedVersion; try { parsedVersion = new Version(serverSoftwareHeader.Substring(slashPos + 1, serverSoftwareHeader.Length - slashPos - 1).Trim()); } catch { parsedVersion = null; } if (productName.EqualsOrdinalIgnoreCase("microsoft-iis") && parsedVersion != null && parsedVersion.Major >= 7) { iisVersion = new Iis7(); } } Iis = iisVersion ?? new Iis6(); Log.IisDetected(Iis, serverSoftwareHeader); } } } }
static void VerifyIisDetected(HttpContext context) { TryInitializeHosting(); if (Iis != null) return; lock (_syncRoot) { if (Iis != null) return; if (context == null) throw new InvalidOperationException(); Iis iisVersion = null; var serverSoftwareHeader = context.Request.ServerVariables[SERVER_SOFTWARE_KEY]; var slashPos = serverSoftwareHeader?.IndexOf('/') ?? -1; if (slashPos != -1) { var productName = serverSoftwareHeader.Substring(0, slashPos); Version parsedVersion; try { parsedVersion = new Version(serverSoftwareHeader.Substring(slashPos + 1, serverSoftwareHeader.Length - slashPos - 1).Trim()); } catch { parsedVersion = null; } if (productName.EqualsOrdinalIgnoreCase("microsoft-iis") && parsedVersion != null && parsedVersion.Major >= 7) { iisVersion = new Iis7(); } } Iis = iisVersion ?? new Iis6(); Log.IisDetected(Iis, serverSoftwareHeader); } }
static void VerifyIisDetected(HttpContext context) { if (Iis == null) { if (context == null) { throw new InvalidOperationException(); } Iis iisVersion = null; string serverSoftwareHeader = context.Request.ServerVariables[ServerSoftwareKey]; int slashPos = serverSoftwareHeader != null ? serverSoftwareHeader.IndexOf('/') : -1; if (slashPos != -1) { string productName = serverSoftwareHeader.Substring(0, slashPos); Version parsedVersion; try { parsedVersion = new Version(serverSoftwareHeader.Substring(slashPos + 1, serverSoftwareHeader.Length - slashPos - 1).Trim()); } catch { parsedVersion = null; } if (productName.EqualsOrdinalIgnoreCase("microsoft-iis") && parsedVersion != null && parsedVersion.Major >= 7) { iisVersion = new Iis7(); } } Iis = iisVersion ?? new Iis6(); Log.IisDetected(Iis, serverSoftwareHeader); } }