作者:Abel Avram译者 郭晓刚 来源:InfoQ 酷勤网收集 2008-07-25
作者是这样描述PowerShellASP的:
PowerShellASP是一种类似ASP的Web应用模板语言;模板里混合了标记(HTML、XML或者随便什么你想生成的标记)和内嵌的PowerShell代码。在运行时,模板/页面被完全翻译成PowerShell代码,并且作为一个单元在PowerShell中执行,结果会被送到客户端的浏览器。
PowerShellASP以ASP.NET平台为支撑,自定义了一个映射到*.ps1x 文件的IHttpHandler。因此你可以在任何ASP.NET应用中随意混入PowerShellASP页面。这种做法非常便于在现有的程序里根据需要利用PowerShellASP,当然完全只用*.ps1x文件从头构建整个程序也是可以的。
用PowerShellASP,Hello World这样写:
<html>
<body>
<hl>Hello <%= $request['name'] %>!</hl>
</body>
</html>
下面的页面可以显示机器上运行的进程:
<html>
<body>
<table>
<tr><td>ID</td>><td>Name</td></tr>
<% get-process | %{ %>
<tr>
<td><%=$_.ID%></td>
<td><%=$_.ProcessName%></td>
</tr>
<% } %>
</table>
</body>
</html>
PowerShellASP可以免费下载,许可协议是PowerShellASP license。
阅读英文原文:ASP.NET Programming Using Windows PowerShell
来自:http://www.infoq.com/cn/news/2008/07/PowerShellASP

