Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Owin Self host & ASP .Net MVC

Tags:

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?

like image 227
Igor Gatis Avatar asked Aug 25 '14 02:08

Igor Gatis


People also ask

What is OWIN self host?

NET (OWIN) defines an abstraction between . NET web servers and web applications. OWIN decouples the web application from the server, which makes OWIN ideal for self-hosting a web application in your own process, outside of IIS.

How do I host OWIN in IIS?

Hosting of OWIN in IIS Use the following procedure. Step 1: Open the Visual Studio and create the "New Project". Step 2: Create the new ASP.NET Web Application and enter the name for the application. Step 3: Select the Empty Project Template to create the application.

What is self hosting in .NET core?

Self Host just means it uses the built-in Web Server, which is in contrast to classic ASP.NET Framework Web Apps which typically requires IIS or the built-in WebDev server to run.


1 Answers

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

like image 191
Daniel Little Avatar answered Sep 17 '22 11:09

Daniel Little