I have a full-working ASP.NET MVC application (.NET Core, ASP.NET Core) which runs fine in Visual Studio (which uses IISExpress).
I would now like to have a console application which takes the ASP.NET Core application and hosts it (self hosting).
It is easy to run your asp.net web application without installing any web server. For running your application without IIS you have to use Cassini Desktop Adapter. Now your application is running without IIS It also support VWG application.
Yes, you could use WebListener web server instead of Kestrel. WebListener only works on the Windows platform but since that is where you are running, it's an option for you.
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.
Hosting a Web API inside IIS is quite straightforward as the process is identical to hosting a web application. On the other hand, hosting a Web API in it's own process requires the creation of a host application and is referred as self-hosting.
Is it possible to self-host an ASP.NET Core Application without IIS?
Yes. In fact, all ASP.NET Core applications are self-hosted. Even in production, IIS/Nginx/Apache are a reverse proxy for the self-hosted application.
In a reasonably standard Program.cs class, you can see the self-hosting. The IISIntegration
is optional - it's only necessary if you want to integrate with IIS.
public class Program { public static void Main(string[] args) { var config = new ConfigurationBuilder() .AddCommandLine(args) .AddEnvironmentVariables(prefix: "ASPNETCORE_") .Build(); var host = new WebHostBuilder() .UseConfiguration(config) .UseKestrel() .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup<Startup>() .Build(); host.Run(); } }
Yes,ASP.NET Core supports the Open Web Interface for .NET (OWIN),your have two options to host your Asp.net core web application:
IIS
Self-Host
But,self-hosting web application can't restart automatically on system boot and restart or in the event of a failure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With