【问题标题】:Create sub domain on different server in asp.net在 asp.net 的不同服务器上创建子域
【发布时间】:2017-07-20 10:35:48
【问题描述】:

我想在 asp.net 中创建子域。在本地 IIS 服务器上,它工作正常,代码生成一个新网站。问题是,我想在服务器(另一台电脑)上创建网站。以下代码在本地 IIS 服务器上生成网站。这是我的代码。提前感谢您的帮助。

 private void createDomain(string domainName, string subDomainName)
        {
            try
            {
                ServerManager serverMgr = new ServerManager();
                string strWebsitename = subDomainName+"." +domainName ; // abc
                string strApplicationPool = "ASP.NET v4.0";  // set your deafultpool :4.0 in IIS
                string strhostname = subDomainName + "." + domainName; //abc.com
                string stripaddress = "192.168.10.25";// ip address
                string bindinginfo = stripaddress + ":80:" + strhostname;

                //check if website name already exists in IIS
                Boolean bWebsite = IsWebsiteExists(strWebsitename);
            
                if (!bWebsite)
                {
                    Site mySite = serverMgr.Sites.Add(strWebsitename.ToString(), "http", bindinginfo, "C:\\inetpub\\TestApp");
                    mySite.ApplicationDefaults.ApplicationPoolName = strApplicationPool;
                    mySite.TraceFailedRequestsLogging.Enabled = true;
                    mySite.TraceFailedRequestsLogging.Directory = "C:\\inetpub\\Logging";
                    serverMgr.CommitChanges();
                   
                }
                else
                {
                    
                }
            }
            catch (Exception ae)
            {
                Response.Redirect(ae.Message);
            }
        } 

我想在服务器中创建如下图所示的网站(另一台带有 IIS 服务器的电脑) Image

【问题讨论】:

    标签: c# asp.net iis webforms


    【解决方案1】:

    您需要告诉服务器管理员您要管理远程机器:

    ServerManager serverMgr = ServerManager.OpenRemote("machineName");
    

    另外,如果在 VS 下运行,请注意以管理员身份运行。

    【讨论】:

    • 谢谢,“machineName”将是该服务器的 IP 地址吗?
    • @InamUrRehman 根据文档,您似乎需要使用远程服务器名称,而不是 ip。另外,请注意您需要为此使用域管理员帐户。 msdn.microsoft.com/es-es/library/…
    • 谢谢@Oscar 这对我很有帮助。
    猜你喜欢
    • 1970-01-01
    • 2015-03-15
    • 2010-10-18
    • 2013-02-21
    • 2012-06-21
    • 2012-01-20
    • 2020-03-23
    • 2015-06-04
    • 1970-01-01
    相关资源
    最近更新 更多