How to access a service deployed locally in IIS express from Visual studio emulator for android

…衆ロ難τιáo~ 提交于 2020-01-02 09:14:28

问题


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.


回答1:


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.




回答2:


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".



来源:https://stackoverflow.com/questions/32109048/how-to-access-a-service-deployed-locally-in-iis-express-from-visual-studio-emula

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!