Domanda

I need a list of all redirect URLs which have been created with virtual directories in IIS 7.5.

Presumably using appcmd, ideally outputing something like:

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

Much appreciated!

È stato utile?

Soluzione

So I guess this isn't possible with appcmd. I queried the IIS configuration file directly (luckily the redirects were configured here and not in individual folder 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"),   
  };
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top