4 using System
.Web
.Hosting
;
6 class TinyHost
: MarshalByRefObject
8 public static TinyHost
CreateHost ()
10 string path
= Directory
.GetCurrentDirectory ();
11 string bin
= Path
.Combine (path
, "bin");
12 string asm
= Path
.GetFileName (typeof (TinyHost
).Assembly
.Location
);
14 Directory
.CreateDirectory (bin
);
15 File
.Copy (asm
, Path
.Combine (bin
, asm
), true);
17 return (TinyHost
) ApplicationHost
.CreateApplicationHost (
18 typeof (TinyHost
), "/", path
);
22 public void Execute (string page
)
24 SimpleWorkerRequest req
= new SimpleWorkerRequest (
25 page
, "", Console
.Out
);
26 HttpRuntime
.ProcessRequest (req
);
31 TinyHost h
= CreateHost ();
32 StreamWriter w
= new StreamWriter ("page.aspx");
33 w
.WriteLine (@"<%@ Page Language=""C#"" %>");
34 w
.WriteLine (@"<% Console.WriteLine(""Hello""); %>");
36 h
.Execute ("page.aspx");