/// <summary> /// Initializes a new instance of the <see cref="T:Netty.NettyServer" /> class. /// </summary> /// <param name="physicalPath">The physical path to the website.</param> /// <param name="virtualPath">The virtual path the website runs on.</param> /// <param name="port">The port the website runs on.</param> /// <param name="enforcePortCheck"><c>true</c> to ensure the port is unused; otherwise, <c>false</c>.</param> /// <exception cref="System.ArgumentNullException"><paramref name="virtualPath"/> is <c>null</c>.</exception> /// <exception cref="System.ArgumentException"><paramref name="port"/> is already in use.</exception> /// <exception cref="System.ArgumentOutOfRangeException"><paramref name="port"/> exceeds the allows TCP port range.</exception> /// <exception cref="System.IO.DirectoryNotFoundException"><paramref name="physicalPath"/> does not exist.</exception> public NettyServer(string physicalPath, string virtualPath, int port, bool enforcePortCheck) { if (virtualPath == null) { throw new ArgumentNullException("virtualPath"); } if (NetworkUtility.IsPortBeingUsed(port)) { throw new ArgumentException(ErrorMessages.PortInUse, "port"); } if (port > NetworkUtility.MaximumPort || port < NetworkUtility.MinimumPort) { throw new ArgumentOutOfRangeException("port"); } var di = new DirectoryInfo(physicalPath); if (!di.Exists) { throw new DirectoryNotFoundException(); } physicalPath = di.FullName; _webConfigFile = Path.Combine(physicalPath, "Web.config"); _originalWebConfig = File.Exists(_webConfigFile) ? File.ReadAllText(_webConfigFile) : null; _webConfigAltered = false; virtualPath = virtualPath[0] == '/' ? virtualPath : "/" + virtualPath; virtualPath = virtualPath[virtualPath.Length - 1] == '/' ? virtualPath : virtualPath + "/"; _config = new AspServerConfiguration() { Initializer = typeof(WebsiteInitializer), PhysicalPath = physicalPath, Port = port, VirtualPath = virtualPath }; }
/// <summary> /// Initializes a new instance of the <see cref="T:Netty.NettyServer" /> class. /// </summary> /// <param name="physicalPath">The physical path to the website.</param> /// <param name="virtualPath">The virtual path the website runs on.</param> public NettyServer(string physicalPath, string virtualPath) : this(physicalPath, virtualPath, NetworkUtility.FindRandomOpenPort(), true) { }