user616
user616

Reputation: 855

IIS to handle api and website on same port

I have an API built with asp.net and its hosted using OWIN.hosting.WebApp as a Windows Service at https://example.com/api/v1/myEndpoint. Its bound to port 443 through netsh. When i start the OWIN application, its done like:

Dim Address As String = "https://*:443/
WebApp.Start(Of Application)(Address)

I also have my website hosted in IIS using SSL and bound to port 443 - https://example.com/web

They both start up and run without error. But it seems like IIS is blocking requests to the https://example.com/api/v1/myEndpoint. Postman cannot reach the API while IIS is running. If i stop IIS and try the exact same postman request the API returns back data like it should. As soon as i start IIS back up, the API will no longer respond.

Is there a rewrite rule i can add to forward the API requests the API service?

Upvotes: 1

Views: 2148

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12814

In my opinion, you could not host the asp.net web API windows service in iis. a single IIS server can host multiple websites, but in order IIS to distribute HTTP requests correctly, each website has to be identified with some unique value. In case of an IIS website, it consists of three attributes that make up a unique combination for each website. These are:

a TCP port number an IP address a host header

The information about the hosted websites is stored in the ServerBindings attribute of the IIS Metabase in the following format: IP:Port:Hostname. Thus, if you want to host multiple websites on the same port, you will have to use a unique Host header or Ip address.

You could refer below link for more detail:

http://woshub.com/run-multiple-websites-on-the-same-port-and-ip-address-on-iis/

Upvotes: 2

Related Questions