应该是HttpRedirect 属性吧,参考
Redirecting in a Script Using the HttpRedirect Metabase Property
http://msdn.microsoft.com/en-us/library/ms525728(v=vs.90).aspx

解决方案 »

  1.   

    状态代码 可能在RedirectHeaders属性里设置,找不到相关源码,你可以手动设置好一个站点,然后用DirectoryEntry query它,看看各个属性都是什么。然后再在代码中模仿。
      

  2.   


    我手动在iis里面建立了一个http301重定向的站点,可是我遍历输出的属性里面没有HttpRedirect
     DirectoryEntry _entry = new DirectoryEntry("IIS://localhost/W3SVC");
                DirectoryEntries _entries = _entry.Children;
             
                foreach (DirectoryEntry _cen in _entries)
                {
                                PropertyCollection props = _cen.Properties;
                    foreach (string prop in props.PropertyNames)
                    {
                        PropertyValueCollection values = props[prop];
                        foreach (object o in values)
                        {
                            Console.Write(prop + ": ");
                            Console.WriteLine(o.ToString());
                        }
                    }
              
                }
                Console.ReadLine();
    是代码写错了吗测试结果图片:(遍历输出的属性里面没有HttpRedirect)
      

  3.   


     using (ServerManager serverManager = new ServerManager())
            {
                Configuration config = serverManager.GetWebConfiguration("http301");            ConfigurationSection httpRedirectSection = config.GetSection("system.webServer/httpRedirect");
                httpRedirectSection["enabled"] = true;
                httpRedirectSection["destination"] = @"http://www.crcz.cn";
                httpRedirectSection["exactDestination"] = true;
                httpRedirectSection["httpResponseStatus"] = @"Permanent";            serverManager.CommitChanges();
            }