使用 NetBox 可以方便的將 asp 應(yīng)用編譯成為獨(dú)立運(yùn)行的執(zhí)行程序,完全擺脫 iis 的束縛,在幾乎所有的 Windows 版本上面直接運(yùn)行,完全不需要考慮平臺(tái)兼容性和對(duì) asp 運(yùn)行環(huán)境的要求。下面就是快速移植已有的 asp 應(yīng)用的步驟。
Dim httpd
Shell.Service.RunService "NBWeb", "NetBox Web Server", "NetBox Http Server Sample"
'---------------------- Service Event ---------------------
Sub OnServiceStart()
Set httpd = CreateObject("NetBox.HttpServer")
If httpd.Create("", 80) = 0 Then
Set host = httpd.AddHost("", "\wwwroot")
host.EnableScript = true
host.AddDefault "default.asp"
host.AddDefault "default.htm"
httpd.Start
else
Shell.Quit 0
end if
End Sub
Sub OnServiceStop()
httpd.Close
End Sub
Sub OnServicePause()
httpd.Stop
End Sub
Sub OnServiceResume()
httpd.Start
End Sub
上面的代碼摘自《創(chuàng)建一個(gè) WEB 服務(wù)器》。其中加粗的部分是缺省文件名,如果你的應(yīng)用不同,可以自行添加修改。
二、復(fù)制 asp 應(yīng)用
在目錄中再創(chuàng)建一個(gè)子目錄:wwwroot,將你在 iis 中的文件全部復(fù)制到 wwwroot 中。此時(shí),你的 asp 運(yùn)行環(huán)境應(yīng)該已經(jīng)準(zhǔn)備好了。