How to access a service deployed locally in IIS ex

2019-05-26 06:13发布

I'm have a WebApi project which gets deployed locally on my machine as http://localhost:6143 or http://127.0.0.1:6143.

However when I try to browse to that endpoint on the visual studio emulator for android browser, I get net:err connection timed out.

Note that on the emulator I'm using http://10.0.2.2:6143 since localhost won't work on the emulator (since it's a vm, localhost refers to itself).

I've also tried 127.0.0.1:6143 and get connection refused.

I also added port 6143 to the incoming firewall rules.

Weird thing is that the other emulators installed by xamarin work very well with no configuration issues.

Any clues why this doesn't work? All my searches and approaches have failed so far.

2条回答
混吃等死
2楼-- · 2019-05-26 06:51

Figured this out after some hunting.

In VS 2015, the applicationhost.config file for asp .net projects is no longer located in the Documents\IISExpress folder. It's now in your project root at .vs\Config.

Once I figured that out, the solution was easy. I went into the config and added a binding as follows (for some reason this was hidden from my original post)

  1. Locate the sites element in the config file for your website/webrole. It's something like:

    `<site name="MySite.Service.WebRole" id="3">`
    
  2. Add a new binding element

    <binding protocol="http" bindingInformation="*:6153:myMachineName" />

That's it. Now within the emulator, I can just access http://myMachineName:6153 to access the service.

查看更多
forever°为你锁心
3楼-- · 2019-05-26 06:52

Conveyor

For this you only need the IP-adress of the Webservice deployed by IIS-Express. To get the IP use the Visual Studio Extension "Conveyor".

查看更多
登录 后发表回答