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