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:
- Comment out lines 92 through 96 of request.cs such that Cassini does not discard requests coming from hosts other than localhost.
- Run build, which builds and installs the Cassini library into the GAC.
- 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.
精彩评论