html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

用C#实现无需iiS环境就可以执行aspx文件_.NET教程_编程技术

[ ] 已经帮助:人解决问题
iis|执行
myhost.cs 编译:
csc MyHost.cs /r:System.Web.dll

using System;
using System.IO;
using System.Web;
using System.Web.Hosting;


public class MyExeHost : MarshalByRefObject {

    public void ProcessRequest(String page)
        {
        HttpRuntime.ProcessRequest(new SimpleWorkerRequest(page, null, Console.Out));
        }

    public static void Main(String[] arguments)
        {
        MyExeHost host = (MyExeHost)ApplicationHost.CreateApplicationHost(typeof(MyExeHost), "/foo", Environment.CurrentDirectory);
           foreach (String page in arguments) {
            host.ProcessRequest(page);
        }
    }
}
test.aspx
<html>
        <body>
                Time is now: <%=Now%>
        </body>
</html>
成功后就可以用下面的方法执行
MyHost.exe Test.aspx > Test.htm
test.htm就是test.aspx执行后的结果
2tzHTML5中文学习网 - HTML5先行者学习网
2tzHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助