下面有一些可怕的錯誤,但我無法弄清楚什麼。 雖然該網站創建爲一種魅力,但應該與其關聯的應用程序池根本不會創建。爲什麼IIS應用程序池完全沒有創建?
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:東西」。你需要解決這個問題。嘗試「*:80:某事」。 –
@LexLi謝謝你,我按要求做了,但問題仍然存在 – OrElse
你的代碼並不是只有一個問題,而是很多。你將不得不找到合適的樣本開始。 –