首页 > Windows开发 > 详细

How to Host ASP.Net Web API on IIS Server

时间:2016-03-10 17:20:27      阅读:242      评论:0      收藏:0      [点我收藏+]

Introduction

In this article I show how to host our ASP .NET Web API on an Internet Information Services (IIS) server. This is useful when we want to host our Web API application in a local host.

Internet Information Services (IIS)

IIS is the acronym for Internet Information Services. It is the set of feature extension modules that are created by Microsoft. IIS is an integral part of the Windows Server products. It supports the Hyper Text Transfer Protocol (HTTP), File Transfer Protocol (FTP), Simple Mail Transfer Protocol (SMTP) etc. IIS is not turned on automatically when Windows is installed.

Benefits of IIS Hosting

  • When we host the Web API in IIS , it is deployed and managed like other IIS applications.
  • When we host the application on IIS, it can provide the process activation and recycling capabilities that increase the reliability of the hosted application.
  • The Web API is hosted on IIS, that simplifies the development and deployment of hosted services.

Now I will define the procedure of hosting the Web API on an IIS server.

Step 1

First open IIS. We can start it from the Start menu; enter "inetmgr" into the search box. The image looks like this:

 技术分享

We can open it using the Control Panel.

  • In the "Control Panel".
  • Click on "Administrative Tools" -> "Internet Information Services (IIS) manager".
  • The image is displayed in the following picture.

技术分享

If you are not able to see the IIS manager then your system might not have IIS installed. For the installation follow this procedure:

  • Open the "Control Panel".
  • "Programs and Feature" -> "Turn Window features on or off".

技术分享

  • There is open the "Windows Feature" window in "tree view".
  • There are checkboxes for installation; select the checkboxes.

技术分享

Step 2

When you will open the Internet Information Services (IIS) manger, the window looks like this:

技术分享

  • Now, right-click on the sites.
  • "Sites" -> "Add Web Site".

技术分享

Open a window. It looks likes this:

技术分享

In this window write the "Site name" here the site name is "Testing" and  provide the Physical path.

When we click on the "Ok" button, a alert box is opened. It display the information about the port; the default port is "80" for the IIS website and if you want to change it then click on the "NO" button.

技术分享

And change the port. Here I will provide the port "8080". And now click on the "OK" button.

技术分享

Now a window is opened that looks like this:

技术分享

When we click on the Testing site from the Sites, then it opens as:

技术分享

Step 3

Now we check the "Advanced setting" from the "right panel". And modify some settings.

技术分享

 

Step 4

Now edit the "Basic settings" in the "Edit Application Pool" in the right panel. In it we select the ".NET Framework version" that is ".NET Framework v4.0.30319" and "Managed pipeline mode" as "Integrated".

 技术分享

Step 5

In this step we are ready to browse our application.

  • Right-click on your website.
  • Select "Manage Web Site" -> "Browse".

技术分享

  • The application is hosted. There is my application "Testing" Host at "8080" port that looks like this:

技术分享

 

Step 6

My application works on Fiddler so we write the URL "http://localhost:8080/api/products". Open the fiddler and click on the Compose tab and enter the URL:

 技术分享

 

The output looks like this:

技术分享

How to Host ASP.Net Web API on IIS Server

原文:http://www.cnblogs.com/luoxiaoxi/p/5262656.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!