Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying .Net Core WebAPI project on IIS

I have created a simple web API using .Net Core and trying to publish it to IIS. But getting HTTP 500.

I followed https://docs.asp.net/en/latest/publishing/iis.html article and did exactly whatever mentioned in that.

I Installed only https://www.microsoft.com/net/download as

DotNetCore.1.0.1-WindowsHosting.exe OPT_INSTALL_REDIST=0

NOTE : I am able to deploy and access MVC application successfully but cannot access WebAPI application with the same steps.

In the IIS logs i am seeing below error.

Failed to start process with commandline '"dotnet" .\Project-1.dll', ErrorCode = '0x80070002'.

I am using the default web api template provided in Visual Studio 2015

am i missing something. Is WebAPI deployment is different to MVC app deployment w.r.t .net core ?

like image 768
Venky Avatar asked Sep 26 '16 13:09

Venky


People also ask

Can we host Web API in IIS?

Self Hosted: You can host ASP.NET Web API using HttpSelfHostServer in Console, Windows Forms, ASP.NET Web Application, ASP.NET MVC application, or in windows services. IIS hosting: You can host your ASP.NET Web API in IIS and use as a webserver to make it available to clients through direct HTTP calls.

Can .NET core run on IIS?

NET Core Library, and the ASP.NET Core Module. The module allows ASP.NET Core apps to run behind IIS. If the Hosting Bundle is installed before IIS, the bundle installation must be repaired. Run the Hosting Bundle installer again after installing IIS.


1 Answers

When you install the .NET Core Windows Server Hosting bundle, it won't restart all of the IIS processes if IIS is currently running. This is a good thing, since on a production server you wouldn't want them just to restart, but it would be nice if it was made a little clearer. First, check your System (not User) PATH variable to ensure that the path to Dotnet is there. Then, go into services and restart the Windows Process Activation Service. This will restart all of the IIS bits and get it to update the path. Once you've done this, IIS should serve up your .NET Core app just fine.

like image 102
Feasoron Avatar answered Sep 21 '22 13:09

Feasoron