代码之家  ›  专栏  ›  技术社区  ›  Nissim

确定网站的协议

  •  1
  • Nissim  · 技术社区  · 14 年前

    我用的是iis6。

    我尝试使用“DirectoryEntry”从以下位置提取所有属性:IIS://localhost/W3SVC/1(1是本例中的站点id)

    结果如下。 如果有人知道使用“DirectoryEntry”以编程方式确定IIS6协议类型的任何其他方法,请告诉我

     AccessFlags = 513 
     AppIsolated = 2
     KeyType = IIsWebVirtualDir
     Path = c:\inetpub\wwwroot
     AppRoot = /LM/W3SVC/1/ROOT 
     AppFriendlyName = Default Application 
     DefaultDoc = Default.htm,Default.asp,index.htm,iisstart.asp
     AnonymousPasswordSync = True
     DirBrowseFlags = 1073741886 
     CacheISAPI = True 
     CGITimeout = 300 
     AuthFlags = 1 
     ContentIndexed = True
     AspLogErrorRequests = True
     AspScriptFileCacheSize = 250
     AspScriptEngineCacheMax = 125
     AspExceptionCatchEnable = True
     AspTrackThreadingModel = False
     AspAllowOutOfProcComponents = True
     AspEnableAspHtmlFallback = False
     AspEnableChunkedEncoding = True
     AspEnableTypelibCache = True
     AspErrorsToNTLog = False
     AspProcessorThreadMax = 25
     AspRequestQueueMax = 3000
     AspMaxDiskTemplateCacheFiles = 1000
     AspAllowSessionState = True
     AspBufferingOn = True
     AspEnableParentPaths = True
     AspSessionTimeout = 20
     AspQueueTimeout = -1 
     AspCodepage = 0 
     AspScriptTimeout = 90 
     AspScriptErrorSentToBrowser = True 
     AppAllowDebugging = False
     AppAllowClientDebug = False
     AspKeepSessionIDSecure = False
     AspEnableApplicationRestart = True
     AspQueueConnectionTestTime = 3
     AspSessionMax = -1 AspLCID = 2048
     AnonymousUserName = IUSR_MASTER
     AspScriptLanguage = VBScript
     AspScriptErrorMessage = An error occurred on the server when processing the URL.  Please  contact the system administrator. 
     AnonymousUserPass = wl60A8PT[Cp@hE
     AspDiskTemplateCacheDirectory = %windir%\system32\inetsrv\ASP Compiled Templates  
     HttpCustomHeaders = X-Powered-By: ASP.NET 
     KeyType = IIsCertMapper
    

    如果不是。。。有人知道如何在IIS 6上使用C#进行检查吗?

    6 回复  |  直到 14 年前
        1
  •  2
  •   JoeBilly    14 年前

    AccessSSLFlags

    像往常一样,您必须在IIS Web服务器根目录上检查此属性,因为IIS逻辑基于虚拟目录。

    路径->IIS://localhost/W3SVC/1/Root

        2
  •  1
  •   Mike Schenk    14 年前

    看起来你需要用 SecureBindings IIsWebServer对象的属性。

    我在自己的windowsserver2003上用SSL和非SSL站点测试了以下代码片段。

    DirectoryEntry di = new DirectoryEntry("IIS://prodweb1/W3SVC/1");
    PropertyValueCollection sslCertHashProperty = di.Properties["SSLCertHash"];
    if (sslCertHashProperty.Count > 0)
    {
      Console.WriteLine("Site has associated SSL Certificate.");
    }
    PropertyValueCollection secureBindingsProperty = di.Properties["SecureBindings"];
    if (secureBindingsProperty.Count > 0)
    {
      Console.WriteLine("Site has at least one SSL (https) binding.");
    }
    PropertyValueCollection serverBindingsProperty = di.Properties["ServerBindings"];
    if (serverBindingsProperty.Count > 0)
    {
      Console.WriteLine("Site has at least one non-SSL (http) binding.");
    }
    
        3
  •  0
  •   Mike    14 年前

    你可以用元数据库来判断。我不知道为什么它不在您的输出中,但是应该有一个像IsSecure=true这样的属性来指示ssl是必需的。如果ssl是可选的,我不认为这个属性是设置的。

        4
  •  -1
  •   Rasmus Faber    14 年前

    如果您可以等到收到请求,则可以使用 Request.IsSecureConnection .

        5
  •  -1
  •   Aaron Saunders    14 年前

    不是很精通C#但是我相信你可以加载web.config文件应用程序中的信息。在那里,您应该能够看到是否有一个特定的安全密钥指示在服务器上配置了SSL。

    Configuration.AppSettings(<key>)
    
        6
  •  -1
  •   John Egbert    14 年前

    您可以检查请求对象。

    HttpContext.Current.Request.ServerVariables["HTTPS"].ToLower() == "on"