예제 #1
0
 public WebServerForm(Server server)
     : base(new ServiceContainer())
 {
     this.InitializeComponent();
     base.Icon = new Icon(typeof(WebServerForm), "WebServerForm.ico");
     base.TaskGlyph = new Bitmap(typeof(WebServerForm), "WebServerForm.bmp");
     this._server = server;
     this._physicalPathTextBox.Text = this._server.PhysicalPath;
     this._appRootTextBox.Text = this._server.VirtualPath;
     this._portTextBox.Text = this._server.Port.ToString();
     this._hyperlinkLinkLabel.Text = this._server.RootUrl;
     this.Text = "Microsoft ASP.NET Web Matrix Server - Port " + this._server.Port;
     this._trayIcon.Icon = new Icon(typeof(WebServerForm), "WebServerTray.ico");
     this._trayIcon.Text = this.Text;
     this._trayIcon.Visible = true;
     this._trayIcon.ShowBalloon("Microsoft ASP.NET Web Matrix Server", this._server.RootUrl, 15);
 }
예제 #2
0
 public static int Main(string[] args)
 {
     CommandLine line = new CommandLine(args);
     bool flag = line.Options["silent"] != null;
     if (!flag && line.ShowHelp)
     {
         ShowUsage();
         return 0;
     }
     string virtualPath = (string) line.Options["vpath"];
     if (virtualPath != null)
     {
         virtualPath = virtualPath.Trim();
     }
     if ((virtualPath == null) || (virtualPath.Length == 0))
     {
         virtualPath = "/";
     }
     else if (!virtualPath.StartsWith("/"))
     {
         if (!flag)
         {
             ShowUsage();
         }
         return -1;
     }
     string path = (string) line.Options["path"];
     if (path != null)
     {
         path = path.Trim();
     }
     if ((path == null) || (path.Length == 0))
     {
         if (!flag)
         {
             ShowUsage();
         }
         return -1;
     }
     if (!Directory.Exists(path))
     {
         if (!flag)
         {
             ShowMessage("The directory '" + path + "' does not exist.");
         }
         return -2;
     }
     int port = 0;
     string s = (string) line.Options["port"];
     if (s != null)
     {
         s = s.Trim();
     }
     if ((s != null) && (s.Length != 0))
     {
         try
         {
             port = int.Parse(s);
             if ((port >= 1) && (port <= 0xffff))
             {
                 goto Label_0153;
             }
             if (!flag)
             {
                 ShowUsage();
             }
             return -1;
         }
         catch
         {
             if (!flag)
             {
                 ShowMessage("Invalid port '" + s + "'");
             }
             return -3;
         }
     }
     port = 80;
     Label_0153:
     try
     {
         Server server = new Server(port, virtualPath, path);
         server.Start();
         Application.Run(new WebServerForm(server));
     }
     catch (Exception exception)
     {
         if (!flag)
         {
             ShowMessage(string.Concat(new object[] { "Web Server failed to start listening on port ", port, ".\r\nError message:\r\n", exception.Message }));
         }
         return -4;
     }
     return 0;
 }
예제 #3
0
파일: Host.cs 프로젝트: ikvm/webmatrix
 private void OnAppDomainUnload(object unusedObject, EventArgs unusedEventArgs)
 {
     Thread.GetDomain().DomainUnload -= this._onAppDomainUnload;
     if (!this._stopped)
     {
         this.Stop();
         this._server.Restart();
         this._server = null;
     }
 }
예제 #4
0
파일: Host.cs 프로젝트: ikvm/webmatrix
 public void Configure(Server server, int port, string virtualPath, string physicalPath, string clientScriptPath)
 {
     this._server = server;
     this._port = port;
     this._installPath = null;
     this._virtualPath = virtualPath;
     this._lowerCasedVirtualPath = CultureInfo.InvariantCulture.TextInfo.ToLower(this._virtualPath);
     this._lowerCasedVirtualPathWithTrailingSlash = virtualPath.EndsWith("/") ? virtualPath : (virtualPath + "/");
     this._lowerCasedVirtualPathWithTrailingSlash = CultureInfo.InvariantCulture.TextInfo.ToLower(this._lowerCasedVirtualPathWithTrailingSlash);
     this._physicalPath = physicalPath;
     this._physicalClientScriptPath = clientScriptPath + @"\";
     this._lowerCasedClientScriptPathWithTrailingSlash = "/aspnet_client/";
     this._onSocketAccept = new WaitCallback(this.OnSocketAccept);
     this._onStart = new WaitCallback(this.OnStart);
     this._onAppDomainUnload = new EventHandler(this.OnAppDomainUnload);
     Thread.GetDomain().DomainUnload += this._onAppDomainUnload;
 }