简体   繁体   中英

IIS7.5 Deployment for Asp.Net Web API

I have gone through all the steps to deploy my Web API in IIS 7.5 on windows server 2008R2 machine in Amazon cloud services. There are other WCF services working on this that can be accessed externally (outside the server) and internally (on the server). so I would like to know where I am going wrong.

I just created a default web api application. You know the one, with the values controller that returns ["Value1","Value2"]. And deployed it.

The steps I follow are:

  1. Create an appropriately named app pool with .Net 4.0 / Integrated selected.
  2. Added a website, selected the app pool in 1, filled in the physical path to my site, gave the relevant http settings (selecting in turn each of the 3 options available to me, All unassigned, ::1, and my machine IP as AAA.BBB.CCC.ETC) and changed the port as both 80 and 8080 are used. So I just used 8081.
  3. Then I unlocked port 8081 in the firewall (just because I taught it might be needed even though the others didn't seem to, I could be wrong about this so I even temporarily turned off my firewall but it still didn't work).

The trick is, when I leave off the binding altogether... that being...If I go into edit bindings. Click on the binding and select edit. Then remove the text in the host name text box. My api works internally (on the server). But I cant access it externally (from another computer). I get "This page cannot be displayed".

When I put the host name back, I cannot get it either internally or externally.

I also cannot get it by typing the IP address of the server even with the port.

As I am using a server in amazon cloud services I am curious if there is some setting I need to do external to the server to make port 8081 available to the outside world? In Azure you need to make the port available outside. I don't know how to do this in Amazon if it's needed.

Just to eliminate false positives: I am aware that .Net 4.5 is a subset of the .Net 4.0 framework and therefore I have researched extensively that my apps should (and indeed does) work even though I can only select .Net 4.0 in the app pool (see after point 3). So I know this is not the problem.

Any help would be appreciated. Let me know if I can clarify any part of the question.

Given that I use SO for my own reference and there has been no answers yet. I decided to answer this myself since I found a solution. If anyone has a better solution please comment or answer. I'm not an network or hardware guy, so I have to put this here for my own reference because I know I'll forget this 6 months from now when next I have to do it.

Essentially all the steps I followed to deploy to IIS was not the problem. Everything I was doing there was 100% correct. After doing the steps below I was able to run the application successfully.

When setting up a physical server you can simply open ports in your firewall to allow access. However if setting up a virtual server, opening ports in the firewall internally on the VM is not enough to get access.

If setting up a VM you must not only open the port internally on the VM, you must also open up the port on the physical machine behind the VM.

If setting this up on the cloud, in azure you have to open the ports externally to the VM. In Amazon the place to do this is currently (it may change) located under the Network & Security tab, Then under Security Groups Sub tab, then pick the VM you want to open the port on, then under the inbound tab, add a custom rule and type the port number. You may or may not need to add an outbound rule too. Essentially, if outbound is set to all, you wont need to add another rule to the outbound.

I hope other people coming here find this helpful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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