【发布时间】:2016-04-30 09:43:18
【问题描述】:
下面有一些严重错误,但我无法弄清楚是什么。 虽然网站创建得像一个魅力,但应该与之关联的应用程序池根本没有创建。
public string Create(string sitename)
{
try
{
using (ServerManager serverMgr = new ServerManager())
{
string strhostname = sitename + "." + domain;
string bindinginfo = ":80:" + strhostname;
if (!IsWebsiteExists(serverMgr.Sites, strhostname))
{
Site mySite = serverMgr.Sites.Add(strhostname, "http", bindinginfo, "C:\\admin\\" + domain);
ApplicationPool newPool = serverMgr.ApplicationPools.Add(strhostname);
newPool.ManagedRuntimeVersion = "v4.0";
newPool.ManagedPipelineMode = ManagedPipelineMode.Integrated;
serverMgr.CommitChanges();
return "Website " + strhostname + " added sucessfully";
}
else
{
return "Name should be unique, " + strhostname + " already exists.";
}
}
}
catch (Exception ex)
{
return ex.Message;
}
}
我在这里做错了什么?
【问题讨论】:
-
绑定信息无效“:80:something”。你需要解决这个问题。试试“*:80:something”。
-
@LexLi 谢谢,我按要求做了,但问题仍然存在
-
您的代码不只是一个问题,而是很多问题。您必须找到合适的样本才能开始。
-
我同意@LexLi。这里提出的问题已经得到解答。在 cmets 中添加补充问题不符合本网站的精神,您应该单独提出这些问题,如果需要,请参考此问题。我很乐意提供帮助,但肯定不会在 cmets 中提供帮助。
标签: c# iis servermanager