2

I wrote an ASP.NET MVC3 site (it contains datamodel, controllers and views). But I want to start hosting this site from code, not using IIS.
I mean, for example, Console application like this:

int Main(string[] argv)
{
    Console.WriteLine("starting web application");
    var webStarter = new SomeWebServerStartingClass(typeof(MvcApplication), 80);
    webStarter.Run();
    Console.WriteLine("closing web application");
}

At line webStarter.Run(); web app is became hosted on 80 port and users can reach it from internet.

ps. I work in a company that develop Computer Vision soft. Our programs realized as windows services. Now we need to create monitoring module in each product. This monitoring module will be asp.net mvc project. I want to start host it from code

pps. I don't want ot use IIS, I just want run this web project from console application. Want to begin receiving requests on specified port just like this webapp was opened in IIS

ppps. Maybe, I want simple package that can host site in code

pppps: I read about self hosting and understood what i want: i want something like ASP.NET Web API Self-Host, but for MVC application with html controllers

Still sorry for English

Alex
  • 183
  • 1
  • 12
  • Do you mean that you are looking for a small webserver that can host ASP.NET MVC and has an open API for control? – James McCormack Aug 28 '12 at 10:50
  • Can you please provide clear requirement? Its doesnt make sense at all. ie you want to publish the project? or start/ stop the application pool in IIS? or run the project without F5? – VIRA Aug 28 '12 at 10:13

3 Answers3

1

Perhaps a product like this is what you're looking for?

http://ultidev.com/products/UWS-Cassini-Pro/

Note: I haven't tried it, but it seems to do what you want.

James McCormack
  • 9,217
  • 3
  • 47
  • 57
  • 1
    No, I don't need applications, I need a library. This still will be our company application, but it will have one more thread in which web app will be hosted – Alex Aug 28 '12 at 11:14
  • ok it looks like what i need, but not working. Now i can say what I need - I need webserver in assembly - assembly that i can add to my console project references that will give me API to host mvc project site from code – Alex Aug 29 '12 at 10:24
  • I don't know much more, but this looks like someone else with a similar question: http://stackoverflow.com/questions/462444/embedded-asp-net-web-server – James McCormack Aug 29 '12 at 18:07
0

Although this question is rather old, I just wanted to point out that using xsp from the mono project offers what you need.

The assemblies you would need are * Mono.Security.dll * Mono.WebServer2.dll

There is a blog post from 2005 which describes how you can use it http://weblogs.asp.net/britchie/archive/2005/07/25/embedding-xsp-mono-webserver-in-your-application.aspx

agez
  • 624
  • 1
  • 7
  • 17
0

It's been a couple of years, and the answer hasn't gotten much better. :)

CassiniDev looks like a good bet at this time, if you're running on Windows.

OWIN+Katana is flavor of the month, but as a Microsoft backed project it raises important life questions, like "do I want to depend on a Microsoft-backed open source project?" and "why does every example insist so emphatically that it is 'easy to use' when it's obviously kind of complicated?"

If you're not on Windows, you're in trouble. I have been searching for a self-hosted, embeddable ASP.NET server that supports mono and "Web Forms" (aka aspx pages). The closest I have found is the mono branch of grendello's fork of the CassiniDev library (whew) at github. These changes have not been incorporated into the main CassiniDev trunk, and I have not tried them yet, but the code looks correct, mostly path separators and the removal of one DLL linkage when not on windows.

tekHedd
  • 411
  • 4
  • 14