Click here to Skip to main content
15,883,796 members
Articles / DevOps
Tip/Trick

Get .NET Core Web API Hosted in IIS

Rate me:
Please Sign up or sign in to vote.
4.70/5 (6 votes)
23 Nov 2017CPOL2 min read 37.6K   663   12   4
Get .NET Core Web API hosted in IIS successfully at your local work station

Introduction

When I create .NET Core Web APIs, I can deploy them in Microsoft Azure portal, then they are hosted in Azure environment and they work very well. But when I deploy them in my local IIS (Internet Information Services), the Web APIs don't work. My article will help you solve this problem. This approach in my article can solve the same problem in Windows 7, Windows 8 and Windows 10 workstations and Servers.

Background

My test system information is as follows:

  • Visual Studio Community 2017
  • .NET Core 2.0
  • Windows 10 Professional
  • Internet Information Services version 10
  • Postman

1. Develop the Web APIs

When you finish developing the Web APIs under .NET Core in Visual Studio 2017 Community 2017, you need to test to make sure your Web APIs are working in Postman.

Press F5 to start your Web API project in Visual Studio. Run Postman with your proper Web API URLs to test to make sure your Web APIs are working.

Image 1

2. Publish the Web APIs to Your Local Folder

You can highlight your Web API project in your solution in Visual Studio and right mouse click “Publish...” to publish your Web API project to your assigned local folder, for example, C:\websites\webApi\BookWebApi.

Image 2

Image 3

3. Install Microsoft .NET Core Windows Server Hosting Bundle File

You can search the web for “.NET Core Windows Server Hosting bundle” file (At my time, it is DotNetCore.2.0.3-WindowsHosting.exe). Install this file in your work station.
<meta charset="utf-8" />

4. Configure Internet Information Services

We need to understand that, per Microsoft:

.NET Core is a general purpose development platform maintained by Microsoft and the .NET community on GitHub. It is cross-platform, supporting Windows, macOS and Linux, and can be used in device, cloud, and embedded/IoT scenarios.

(1) Create One Application Pool of No Managed Code

.NET Core is not dependent on the managed code environment. Therefore, we need to create one application pool of No Managed Code at IIS. You can highlight “Application Pools” and right mouse click to “Add Application Pool…” , for example, NoManagedCodePool.

Image 4

Image 5

Image 6

(2) Create Your Web Site

In IIS, you can highlight “Sites” and right mouse click to “Add Website…”, for example, BookWebApi, to point to the local folder of your published Web API code, for example, C:\websites\webApi\BookWebApi, and use “NoManagedCodePool” with port 9001.

Image 7

Image 8

Start your web site for your Web APIs.

4. Test Your Web APIs Hosted in IIS

Now you can use Postman to test your Web APIs hosted in IIS.

Image 9

Then you have successfully hosted your Web APIs developed with .NET Core in IIS locally.

Happy coding!

Points of Interest

When the new technology comes to me, I always need to find the ways to get the new tech working. This is the fun of changing technology and the fun of the changing world! Constantly changing is no change!

History

  • 23rd November, 2017: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
C# and .NET Core
Typescript, node.js, jQuery, jQuery Mobile
Web Api and MVC
Angular and AngularJS
Azure
Databases (SQL Server and Oracle) and No-SQL Databases
Agile and Waterfall

Comments and Discussions

 
QuestionThanks Pin
amtadhani12-Apr-19 8:24
amtadhani12-Apr-19 8:24 
QuestionThank You Pin
Arean Narrayan20-Jan-19 19:54
Arean Narrayan20-Jan-19 19:54 
GeneralThank You Pin
Priyanka Kale21-Feb-18 21:15
Priyanka Kale21-Feb-18 21:15 
GeneralMy vote of 4 Pin
Hyland Computer Systems27-Nov-17 15:23
Hyland Computer Systems27-Nov-17 15:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.