Owin Self host & ASP .Net MVC

匿名 (未验证) 提交于 2019-12-03 02:08:02

问题:

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?

回答1:

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).



回答2:

Have a look at this link, it works for me http://www.dotnetcurry.com/showarticle.aspx?ID=896

Updated: The above comment only valid for webapi, not MVC site



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!