简体   繁体   English

从URL Web API删除端口号

[英]Remove port number from URL web API

I've created a web API and hosted it on IIS 7.0, but the default port hosts another web application. 我已经创建了一个Web API并将其托管在IIS 7.0上,但是默认端口托管了另一个Web应用程序。 Therefore, I specified another port for the WEB API. 因此,我为WEB API指定了另一个端口。 The issue is how the web API is accessed as it includes the port number along with the URL. 问题在于如何访问Web API,因为它包括端口号和URL。 I want to remove this port dependency or at least hide it. 我想删除此端口依赖性或至少隐藏它。

So instead of http://website:26018/api/products?brand_id=2,3 因此,而不是http:// website:26018 / api / products?brand_id = 2,3

I want it to be accessible from a URL like this: 我希望可以从这样的URL访问它:

http://website/api/products?brand_id=2,3 http:// website / api / products?brand_id = 2,3

How can I achieve this? 我该如何实现?

The http specification RFC2616 (Section 3.2.2) states that http规范RFC2616 (第3.2.2节)规定:

If the port is empty or not given, port 80 is assumed. 如果端口为空或未提供,则假定端口为80。

Therefore, to omit the port number, you will have to put your application on port 80. 因此,要省略端口号,必须将应用程序放在端口80上。

IIS allows you to redirect traffic coming from a specific DNS address to your application. IIS允许您将来自特定DNS地址的流量重定向到您的应用程序。 Take a look at this article: http://www.visualwin.com/Host-Header/ 看一下这篇文章: http : //www.visualwin.com/Host-Header/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM