我可以使用以下代码在IIS中创建http重定向。但是,它仅为主站点“MySite”本身创建重定向。如何以编程方式将重定向添加到虚拟目录?创建VD时是否需要设置一些设置?谢谢!如何使用C#从虚拟目录创建HTTP重定向
ServerManager iisManager = new ServerManager();
Configuration config = iisManager.GetWebConfiguration("MySite");
ConfigurationSection httpRedirectSection = config.GetSection("system.webServer/httpRedirect");
httpRedirectSection["enabled"] = true;
httpRedirectSection["destination"] = @"http://www.google.com";
httpRedirectSection["exactDestination"] = false;
httpRedirectSection["httpResponseStatus"] = @"Found";
iisManager.CommitChanges();
我的意思是“从”虚拟目录中读取了。如果用户转到http://MySite/VD.aspx,它会将它们重定向到另一个页面。我需要能够通过C#添加这些。 – 2011-06-02 20:03:32