在IIS中更改站点的Physicalpath属性 [英] Changing physicalpath property of a site in IIS

查看:536
本文介绍了在IIS中更改站点的Physicalpath属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Microsoft.Web.Administration在C#中以编程方式创建网站,如下所示.



如果该站点存在于IIS中,则我尝试更改如下所示的绑定.

Hi All,

I am creating site programmatically in c# using Microsoft.Web.Administration as below.



and if the site exists in IIS, I am trying to change the bindings as below.

 Microsoft.Web.Administration.ServerManager mgr = new Microsoft.Web.Administration.ServerManager();
                Microsoft.Web.Administration.Site site = null;
if (!DoesWebSiteExist(SITE))
               {

                   if (!System.IO.Directory.Exists(physicalPath))
                   {
                       System.IO.Directory.CreateDirectory(physicalPath);
                   }
                   site = mgr.Sites.Add(SITE, physicalPath, System.Convert.ToInt32(ASPORT));
                   site.ApplicationDefaults.ApplicationPoolName = POOL;
                   site.Bindings.Clear();
                   site.Bindings.Add(bindinfo, "http");
                   site.ServerAutoStart = true;
                   mgr.CommitChanges();
               }
               else
               {
                   site = mgr.Sites[SITE];
                   site.ServerAutoStart = true;
                   site.Bindings.Clear();
                   site.Bindings.Add(bindinfo, "http");
                   site.ServerAutoStart = true;
                   mgr.CommitChanges();
               }



如果站点已经存在,我想更改站点的物理路径.我怎样才能做到这一点 ?帮助非常感谢.

谢谢
PMM



I want to change the physical path of the site if the site already exists. How can i do that ? Help much appreciated.

Thanks
PMM

推荐答案

我找到了.

I found it.

site.Applications["/"].VirtualDirectories["/"].PhysicalPath = physicalPath;



谢谢
PMM



Thanks
PMM


这篇关于在IIS中更改站点的Physicalpath属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆