self hosting asp.net mvc

Daniel Powell picture Daniel Powell · Apr 30, 2012 · Viewed 17.3k times · Source

Is it possible to self host asp.net mvc inside another application ie. console, windows forms, service etc etc.

I'd like to build an app that offers a web interface to control it and I'd like to use asp.net mvc for the web part of it.

I did take a quick look at Nancy which looks like it would work, though its not asp.net mvc it did support razor although it doesn't have quite the same level of support for it as asp.net (eg. strongly typed views)

I did also find this question but it doesn't really go into much depth Possible to use ASPNET MVC2 without IIS?

Answer

bloudraak picture bloudraak · Apr 30, 2012

You can use "IIS 7.0 Hostable Web Core" and host the web server as part of any user process, even a console application. The benefit is that it is very similar to full blown IIS (incl config etc) but the web server itself is running in your process.

Have a look at the following articles:

  1. Host your own Web Server in your application using IIS 7.0 Hostable Web Core
  2. Creating Hosted Web Core Applications