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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public static void IisDetected(this ILogger<AspNetLogSource> log, Iis iisVersion, string productHeader)
 {
     log.WriteDebug("Loaded IIS abstraction {0} for product header \"{1}\".", iisVersion.GetType().Name, productHeader);
 }
 public static void IisDetected(this ILogger <AspNetLogSource> log, Iis iisVersion, string productHeader)
 {
     log.WriteDebug("Loaded IIS abstraction {0} for product header \"{1}\".", iisVersion.GetType().Name, productHeader);
 }
Ejemplo n.º 4
0
 static bool HandlerAlreadyMapped(string method, Uri path)
 {
     return(Iis.IsHandlerAlreadyRegisteredForRequest(method, path));
 }