看了一篇asp.net outside iis的小代码,原文在这里。可,这个outside显然 outside不过潇洒 : 原代码好象有点小的错误。一看就知道了,顺手把它“翻译”成VB的。
哎!全世界的代码好象都在C#的闺房里赖着,“真理”总是由C#的“脸皮”来扮演!学VB的真是难堪:右眼看VB代码,左眼看C#代码,双手又来打VB CODE!
MyExeHost.VB
------------------------------------------
Imports System
Imports System.IO
Imports System.Web
Imports System.Web.Hosting
Public Class MyExeHost : Inherits MarshalByRefObject
Public Sub PresscessRequest(ByVal page As String)
HttpRuntime.ProcessRequest(New SimpleWorkerRequest(page, Nothing, Console.Out))
End Sub
Public Shared Sub Main(ByVal arguments() As String)
Dim host As MyExeHost = ApplicationHost.CreateApplicationHost(GetType(MyExeHost), "/", Directory.GetCurrentDirectory)
Dim page As String
For Each page In arguments
host.PresscessRequest(page)
Next
End Sub
End Class
测试页面:
Test.aspx
----------------------------------
<html>
<body>
Hello!World!
Time is now: <%=Now%>
</body>
</html>
执行步骤参看这里(执行的图片).
要提一点的是,必须在CURRENTDIRCTORY目录下再建一个BIN目录,把VBC编译后的MyExeHost.EXE放在这个目录中,程序才可以正常运行。具体原因,我说不太清楚的,模糊!哪位大哥讲一下呢?!