0

Can I host an ASP.NET (MVC5 if it matters) webapplication be hosted inside a normal console, UI or windows-service application? Where to start without web.config?

Background is that I need a master service providing WCF services and other management while I would like to present an UI with ASP.NET MVC.

Having the ASP.NET web application in a seperate assembly and hosting is started by the main assembly would be acceptable.


Because of the many comments I would like to add:

The system already self-hosts some WCF-services. These could also serve HTML but that would be like reinventing the wheel. I do not like to have IIS as dependency, the application should provide everything out of itself. As the WCF-services uses some endpoint-definitions and ServiceHost it seems tempting to add a required HTML-UI just like other services.

But I am also willing to investigate other methods. But that would mean to have two listeners which seems - not so good.

ZoolWay
  • 5,411
  • 6
  • 42
  • 76
  • What's wrong with hosting the MVC application in IIS? – xxbbcc Feb 25 '14 at 18:56
  • @xxbbcc There might not nothing "wrong" as such, but there is an interest in the community to host web apps outside IIS (in windows service for example). But in this particular case, MVC is not hostable outside IIS as there is a strong dependency on System.Web. – Simon Belanger Feb 25 '14 at 19:25
  • @SimonBelanger I didn't mean to imply that it's 'wrong' to do this - but hosting a web application in a console doesn't seem to make much sense so I was curious. – xxbbcc Feb 25 '14 at 19:35
  • @SimonBelanger Shouldn't System.Web be available without IIS, too? – ZoolWay Feb 25 '14 at 19:45
  • 1
    @ZoolWay Yes it is. But as far as hosting goes, System.Web registers itself as an HttpModule to IIS. MVC relying on System.Web to respond to HttpRequest means it requires a module to be registered on IIS. You can, of course, pull System.Web and use the helpers and what not with no problem. But running an MVC application will depend on System.Web IHttpModule registration with IIS if you want anything coming in. You can't use a simple TcpListener or any other alternative as a channel to communicate. – Simon Belanger Feb 25 '14 at 19:48
  • 2
    @ZoolWay There is a recent talk with Scott Hanselman and Louis DeJardin that might be of interest regarding the relationship and ties between System.Web and IIS. The talk is about the project Helios but the introduction is of interest to this topic. [Building Modern Web Apps: (07) ASP.NET "Project Helios"](http://channel9.msdn.com/Series/Building-Modern-Web-Apps/07) – Simon Belanger Feb 25 '14 at 19:51
  • Another idea: WCF services can selfhost themselves too. With `ServiceHost` – ZoolWay Feb 25 '14 at 19:54
  • OWIN/KATANA is some hot topic these days. I would wait for it to be more mature. – DarthVader Feb 25 '14 at 20:06

2 Answers2

1

Look at katana project. http://www.asp.net/vnext/overview/owin-and-katana You can host your application in console or windows service. Example: http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api

Jernej Novak
  • 3,165
  • 1
  • 33
  • 43
0

Besides Novak's answer you can check this one out:

http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api

It is for a web API application but you could also make it work for a ASP.NET app.

Jportelas
  • 646
  • 10
  • 21