做此程序的原因是将软件部署简化,省去IIS的麻烦部署,减少项目实施人员的工作量和工作复杂度
Server sv = new Server(8000, "/", @"D:/web", ipAddress.Any, null, "Login.aspx");
// **********************************************************************************// CassiniDev - http://cassinidev.codeplex.com// // Copyright (c) 2010 Sky Sanders. All rights reserved.// Copyright (c) Microsoft Corporation. All rights reserved.// // This source code is subject to terms and conditions of the Microsoft Public// License (Ms-PL). A copy of the license can be found in the license.txt file// included in this distribution.// // You must not remove this notice, or any other, from this software.// // **********************************************************************************#regionusing System;using System.Collections.Generic;using System.Diagnostics;using System.Globalization;using System.IO;using System.Net;using System.Net.Sockets;using System.Reflection;using System.Runtime.Remoting;using System.Security.Permissions;using System.Security.PRincipal;using System.Text;using System.Threading;using System.Web;using System.Web.Hosting;#endregionnamespace SimpleWebServer{ ///<summary> ///</summary> [PermissionSet(SecurityAction.LinkDemand, Name = "Everything"), PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")] public class Server : MarshalByRefObject, IDisposable { ///<summary> ///</summary> public List<string> Plugins = new List<string>(); ///<summary> ///</summary> public readonly applicationManager ApplicationManager; private readonly bool _disableDirectoryListing; private readonly string _hostName; private readonly IPAddress _ipAddress; private readonly object _lockObject; private readonly string _physicalPath; private readonly int _port; private readonly bool _requireAuthentication; //private readonly int _timeoutInterval; private readonly string _virtualPath; private bool _disposed; private Host _host; private IntPtr _processToken; private string _processUser; //private int _requestCount; private bool _shutdownInProgress; private Socket _socket; //private Timer _timer; private string _appId; private string _dfPage; ///<summary> ///</summary> public string AppId { get { return _appId; } } ///<summary> ///</summary> public AppDomain HostAppDomain { get { if (_host == null) { GetHost(); } if (_host != null) { return _host.AppDomain; } return null; } } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> public Server(int port, string virtualPath, string physicalPath) : this(port, virtualPath, physicalPath, false, false) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="physicalPath"></param> public Server(int port, string physicalPath) : this(port, "/", physicalPath, IPAddress.Loopback) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="ipAddress"></param> ///<param name="hostName"></param> ///<param name="requireAuthentication"></param> public Server(int port, string virtualPath, string physicalPath, IPAddress ipAddress, string hostName) : this(port, virtualPath, physicalPath, ipAddress, hostName,false, false, null) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="requireAuthentication"></param> public Server(int port, string virtualPath, string physicalPath, bool requireAuthentication) : this(port, virtualPath, physicalPath, requireAuthentication, false) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="ipAddress"></param> ///<param name="hostName"></param> public Server(int port, string virtualPath, string physicalPath, IPAddress ipAddress, string hostName,string dfPage) : this(port, virtualPath, physicalPath, ipAddress, hostName, false, false, dfPage) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="ipAddress"></param> ///<param name="hostName"></param> ///<param name="requireAuthentication"></param> ///<param name="disableDirectoryListing"></param> public Server(int port, string virtualPath, string physicalPath, IPAddress ipAddress, string hostName, bool requireAuthentication, bool disableDirectoryListing, string dfPage) : this(port, virtualPath, physicalPath, requireAuthentication, disableDirectoryListing) { _ipAddress = ipAddress; _hostName = hostName; if (!String.IsNullOrEmpty(dfPage)) dfPage.TrimStart('/'); _dfPage = "/" + dfPage; //_timeoutInterval = timeout; } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="ipAddress"></param> public Server(int port, string virtualPath, string physicalPath, IPAddress ipAddress) : this(port, virtualPath, physicalPath, ipAddress, null, false, false , null) { } ///<summary> ///</summary> ///<param name="port"></param> ///<param name="virtualPath"></param> ///<param name="physicalPath"></param> ///<param name="requireAuthentication"></param> ///<param name="disableDirectoryListing"></param> public Server(int port, string virtualPath, string physicalPath, bool requireAuthentication, bool disableDirectoryListing) { try { Assembly.ReflectionOnlyLoad("Common.Logging"); } // ReSharper disable EmptyGeneralCatchClause catch // ReSharper restore EmptyGeneralCatchClause { } _ipAddress = IPAddress.Loopback; _requireAuthentication = requireAuthentication; _disableDirectoryListing = disableDirectoryListing; _lockObject = new object(); _port
新闻热点
疑难解答