Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Kestrel behind IIS

I have a problem in running an asp.net core website on remote server. I want to use kestrel with IIS ,and published it in visual studio 2017 It's my program.cs:

public static void Main(string[] args)
{
var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseUrls("http://example.com")
            .UseIISIntegration()
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .Build();
host.Run();
}

At the remote server when I double click on myWebAppName.exe the kestrel run and very fast closed What i must do? pleas, help me

like image 494
Babak irannezhad Avatar asked Sep 13 '25 21:09

Babak irannezhad


1 Answers

First of all: you don't need to click on app .exe file if you want to host in IIS. Doing this you run it as a standalone application. Instead you should create a IIS Website.


Configuration via code is only one of steps. You need also configure IIS to host your app. Follow this Set up a hosting environment for ASP.NET Core on Windows with IIS, and deploy to it official documentation to setup everything right.

Note: some steps are different for varied ASP.NET Core versions.

like image 73
Set Avatar answered Sep 16 '25 15:09

Set