C#操作IIS问题--C#程序中如何为IIS新增一个站点
C#操作IIS问题--C#程序中如何为IIS新增一个站点
注意:
是新增一个站点,不是虚拟目录哟。以及怎么设置端口号与主机头?
------解决方案--------------------up
------解决方案--------------------大年初一 凌晨帮顶
------解决方案--------------------using System;
using System.Data;
using Wooyea.WebSite.Modules.Hosts.DataAccess;
using Wooyea.WebSite.Modules.Hosts.Configuration;
namespace Wooyea.WebSite.Modules.Hosts.Business
{
public class HostService
{
#region Private fields
private ModuleSettings settings;
private int id;
private string name;
private string description;
private decimal price;
private string ip;
private int port;
private string rootPath;
private int maxBandwidth;
private int maxConnections;
private int cpuLimit;
private byte serverSize;
private byte appIsolated;
#endregion
#region Properties
public int ID
{
get {return id;}
set {id = value;}
}
public string Name
{
get {return name;}
set {name = value;}
}
public string Description
{
get {return description;}
set {description = value;}
}
public decimal Price
{
get {return price;}
set {price = value;}
}
public string IP
{
get {return ip;}
set {ip = value;}
}
public int Port
{
get {return port;}
set {port = value;}
}
public string RootPath
{
get {return rootPath;}
set {rootPath = value;}
}
public int MaxBandwidth
{
get {return maxBandwidth;}
set {maxBandwidth = value;}
}
public int CpuLimit
{
get {return cpuLimit;}
set {cpuLimit = value;}
}
public byte ServerSize
{
get {return serverSize;}
set {serverSize = value;}
}
#endregion
public HostService()
{
Configuration.ModuleConfig config = new ModuleConfig();
settings = config.GetSettings();
}
public HostService(string name, string description, decimal price, string ip, string rootPath) : this()
{
this.name = name;
this.description = description;
this.price = price;
this.ip = ip;
this.rootPath = rootPath;
}
public HostService(int id) : this()
{
this.id = id;
GetDetails();
}
public void GetDetails()
{
DataAccess.HostServices dataHostServices = new Wooyea.WebSite.Modules.Hosts.DataAccess.HostServices(settings.ConnectionString);
DataRow tempRow = dataHostServices.GetDetails(id);
this.name = (string)tempRow[ "HostServiceName "];
this.price = Convert.ToDecimal(tempRow[ "HostServicePrice "]);
this.ip = (string)tempRow[ "HostServiceIP "];
this.port = (int)tempRow[ "HostServicePort "];
this.rootPath = (string)tempRow[ "HostServiceRootPath "];
}
public DataSet GetHostServices()
{
DataAccess.HostServices dataHostServices= new Wooyea.WebSite.Modules.Hosts.DataAccess.HostServices(settings.ConnectionString);
return dataHostServices.GetHostServices();
}
public int Create()
{
DataAccess.HostServices dataHostServices= new Wooyea.WebSite.Modules.Hosts.DataAccess.HostServices(settings.ConnectionString);
return dataHostServices.Insert(name, description, price, rootPath, ip);