Android: “Bad Request-Invalid Hostname” When accessing localhost from emulators

后端 未结 3 1135
粉色の甜心
粉色の甜心 2020-12-31 08:42

I am not able to use localhost with xamarin.android application. I have executed Web project & Service project(not mobile app) on Chrome Browser.

The di

3条回答
  •  北荒
    北荒 (楼主)
    2020-12-31 09:07

    Open your solution folder. You might have several projects inside 1 folder, you don't need project's folder but the root one. Inside you'd have .vs/config/applicationhost.config file, open it.

    find inside you'll have sites that you are running, might have several, if you switch startup projects in one solution. The name will be corresponding to one displayed by IIS in taskbar when you right-click it's icon. The tag could be, for example, . Now you need to add a line to bind external connections to your machine ip, for example

          
    ...
            
    ...
              
            
          
    

    Set appropriate port number and protocol, what matters here is just map them to 127.0.0.1, not "localhost" then they will be available for android emulator via 10.0.2.2:60424 (the port number 60424 is just from the example above, use yours)

提交回复
热议问题