iis6版本方法。。。
iis7以及以上版本方法
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(); }