我可以使用以下代碼在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