开发者

Console App Host ASPX Page?

In Framework 4.0 I have a little console app. I have a self-contained .aspx page (no codebehind) and would like to run the console app just to host this page. I searched around for tricks with System.ServiceModel.Web or System.Web.开发者_JAVA百科Services trying to find a way to do this.

Can anyone help me get clue?

Thanks.


Have you seen this article? It's not written for asp.net 4.0, it's written for asp.net 2.0, but I don't think there's much difference.


The easiest way to host ASP.NET on a simple web server is to use the Cassini web server, which you can download from MS, including source code. The following two links help:

  • http://en.wikipedia.org/wiki/Cassini_Web_Server
  • http://www.asp.net/downloads/archived-v11/cassini

After downloading, the only things you need to do are:

  1. Comment out lines 92 through 96 of request.cs such that Cassini does not discard requests coming from hosts other than localhost.
  2. Run build, which builds and installs the Cassini library into the GAC.
  3. Run the server.

Note: Cassini is a Console app, which just happens to show a form. If you're interested in it working purely as a Console app, refactor and remove the form. It should not be hard.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜