Access IIS Express from Web API from

1.3k Views Asked by At

First let me say this used to work in Visual Studio 2015 but I am having the a darn hard time getting it to work in Visual Studio 2017.

I have a WebAPI project running in Visual Studio 2017. I have edited the applicationhost.config file in the …\ProjectName.vs\config file so it has the following entries for my project.

            <bindings>
                <binding protocol="http" bindingInformation="*:56952:localhost" />
                <binding protocol="http" bindingInformation="*:56952:192.168.1.155" />
            </bindings>

My firewall is completely disabled. When I try to run my Xamarin forms project on a Win10 Mobile V10.0.15254.0 emulator my app does not connect to the WebAPI. (I get the standard "The text associated with this error code could not be found. A connection with the server could not be established."

If I launch Edge on the emulator and try to access any of my local servers on the network using IP address, that works. Can someone enlighten me with regard to what has changed and how I can now make this work?

1

There are 1 best solutions below

0
George M Ceaser Jr On

So the issue was the IP address I was using. Here are the steps I used to resolved this:

  1. I launched my Windows 10 mobile emulator.
  2. Click on the >> (Tools) icon in the tool bar of the emulator.
  3. Click on the Network tab of the Additional Tools window.
  4. I looked in the list for the network adaptor labeled Desktop Adaptor #1 and copied the IP address.
  5. Edit the Applicationhost.config file in the folder of the WebAPI project.
  6. Find the entry in the file for site name="XXXXX" where XXXXX is the name of the Visual Studio project you are hosting your WebAPIs in.
  7. Within the <bindings> section of the entry for your WebAPI project, add a binding for the IP address you copied from in step 4. It should look something like this:

    <binding protocol="http" bindingInformation="*:56952:169.254.69.220" />
    

Where 56952 is the port my IIS Express is hosting the WebAPIs on and 169.254.69.220 is the IP address I copied from step 4.

After adding this, I was able to connect to locally hosted WebAPIs in IIS Express.

Hope this helps.