Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have an ASP .Net MVC app which works just fine under IIS. I need to be able to run the same app from a self hosted console app. How do I do that? Should I use OWIN? What the code should look like?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
718 views
Welcome To Ask or Share your Answers For Others

1 Answer

Update

Now that ASP.NET Core is out there are a few ways to Self Host a web application. One option is to use an OWIN based web server such as Nowin.

var host = new WebHostBuilder()
    .UseNowin()
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseStartup<Startup>()
    .Build();

Alternatively, Kestrel has also been a popular choice for hosting ASP.NET Core applications.

var host = new WebHostBuilder()
    .UseUrls("http://*:1000") // default URL
    .UseKestrel()
    .Build();

Original Answer

You cannot self host ASP.NET MVC 5 (the current version of MVC). However you can use NancyFx today or have a look at ASP.NET vNext which does support OWIN.

Note you can also use WebApi with OWIN today if you need to make single page apps (but then it's not server side MVC).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...