【发布时间】: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
【问题讨论】: