Cool Tool: Cassini here power toy
[…]The .NET Framework 2.0 comes with a built-in webserver, based on the old Cassini web server. So I wanted to be able to easily set up any directory to have its contents served up on an as-needed basis. The result is an addition to the Windows Explorer right-click menu…[Robert McLaws]
Chris Fraizer wrote it thgether in a small app.
Here is my version with a few modifications:
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Forms;
using System.Text;
using System.Runtime.InteropServices;
namespace WebServerHere
{
class Program
{
static void Main(string[] args)
{
if (args.Length >= 1)
{
string _path;
string _command =
Path.Combine(
RuntimeEnvironment.GetRuntimeDirectory(),
"WebDev.WebServer.EXE");
StringBuilder _commandArgs = new StringBuilder();
Random _r = new Random();
string _port = _r.Next(1024, 9000).ToString();
if (args.Length == 2)
{
_port = args[1];
}
//grab the original path
_path = args[0];
_commandArgs.Append(" /path:\"");
_commandArgs.Append(_path);
_commandArgs.Append("\"");
_commandArgs.Append(" /port:");
_commandArgs.Append(_port);
_commandArgs.Append(" /vpath: \"/");
_commandArgs.Append(_path.Substring(
_path.LastIndexOf('\\') + 1));
_commandArgs.Append("\"");
ProcessStartInfo _info =
new ProcessStartInfo();
_info.Arguments = _commandArgs.ToString();
_info.CreateNoWindow = true;
_info.FileName = _command;
_info.UseShellExecute = false;
_info.WorkingDirectory =
_command.Substring(0, _command.LastIndexOf('\\'));
Process.Start(_info);
using (Control _c = new Control())
{
Help.ShowHelp(_c, "http://localhost:" + _port + "/");
}
}
else
{
MessageBox.Show("Usage:\n\tWebServerHere.exe <path> [port]",
"WebServerHere", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
}
}
}
And the Non-Admin installation reg-file:
Windows Registry Editor Version 5.00
[HKEY_Current_User\SOFTWARE\Classes\Folder\shell\VS2005 WebServer]
@="ASP.NET 2.0 Web Server Here"
[HKEY_Current_User\SOFTWARE\Classes\Folder\shell\VS2005 WebServer\command]
@="\"%SystemRoot%\\System32\\WebServerHere.exe\" %1"