赛迪网 >> 技术应用子站 >> ASP
用C#实现无需iiS环境就可以执行aspx文件
作者: 来源:cfan 发布时间:2006.07.26
【Java专区】 【网络安全】 【网管专区】 【linux专区】 【数据库专区】 【进入论坛】 【IT博客】 
【Eclipse】  【PHP】  【DB2】  【Ajax】  【Struts】  【Spring】 

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.


最全面的笔记本导购资讯,给您全方位的笔记本导购平台
评论】 【推荐】 【 】 【打印】 【关闭
*姓  名: 更多资料 了解方案 认识厂商
*单位名称:
*联系电话:
*电子邮件:
    
◆ 相关文章
· asp.net datagrid如何在最后一行作求和: 2003-10-28
· .NET Framework環境下的ASP網頁製作(2)(王国荣) 2005-07-17
· 解决一个比较奇怪的NET问题的方法 2003-02-11
· ASP.NET移植须知 2004-11-19
· Coalesys.WebMenu source code(partial)(8) 2005-11-01