Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
列出IIS站点中的所有虚拟目录重定向_Iis_Iis 7.5_Appcmd - Fatal编程技术网

列出IIS站点中的所有虚拟目录重定向

列出IIS站点中的所有虚拟目录重定向,iis,iis-7.5,appcmd,Iis,Iis 7.5,Appcmd,我需要一个所有重定向URL的列表,这些URL是在IIS 7.5中使用虚拟目录创建的 可能使用appcmd,理想情况下输出如下内容: /foo http://example.com/blah /bar http://another.example.com/ 301 非常感谢 所以我想这在appcmd中是不可能的。我直接查询了IIS配置文件(幸运的是重定向是在这里配置的,而不是在单独的文件夹web.configs!) var config = XElement.Load (@"C:\path\

我需要一个所有重定向URL的列表,这些URL是在IIS 7.5中使用虚拟目录创建的

可能使用appcmd,理想情况下输出如下内容:

/foo  http://example.com/blah
/bar  http://another.example.com/ 301

非常感谢

所以我想这在appcmd中是不可能的。我直接查询了IIS配置文件(幸运的是重定向是在这里配置的,而不是在单独的文件夹web.configs!)

var config = XElement.Load (@"C:\path\to\applicationHost.config");

var query =
  from location in config.Elements("location")
  let webServer = location.Element("system.webServer")
  where webServer != null
  let redirect = webServer.Element("httpRedirect")
  where redirect != null
  where (string) redirect.Attribute("enabled") == "true"
  let path = (string) location.Attribute("path")
  where !String.IsNullOrWhiteSpace(path)
  orderby path
  select new
  {
       path,
       destination = (string) redirect.Attribute("destination"),
       exactDestination =  (string) redirect.Attribute("exactDestination"),
       childOnly =  (string) redirect.Attribute("childOnly"),
       httpResponseStatus =  (string) redirect.Attribute("httpResponseStatus"),   
  };