You've just started a new project and decided you want to try out asp.net core 3.0 for your API π.
File -> New ... Run your API and you are instantly showered with JSON test data π
Great work πͺ.
There is just one problem, if you are building this backend for a mobile app, you'll immediately run into that Aha moment, where you instantly remember that you can't access localhost from the emulator π
No problem, I'll just change "localhost" to the actual IP of my laptop and that will be the end of it π
Nop, nice try. That will get you one step closer, but now we are dealing with another problem π.
What is going on π? The problem here is that IIS Express (used by default in VS2019) is only mapping requests for that port to "localhost".
Luckily this is very easy to fix π
1οΈβ£ Open up the .vs folder π
It is in the root of your solution. It's hidden by default, make sure to enable "Hidden items" in Explorer.
2οΈβ£ Fire up Visual Studio Code π₯
Once inside, go to .vs[Your solution name]\config\ and find the applicationhost.config file. Open it up with VSCode.
3οΈβ£ Change the Bindings β
Specifically we are looking for the bindings that are using the same port number and are pointing to localhost. It should look something like this π
<bindings>
<binding protocol="http" bindingInformation="*:53391:localhost" />
<binding protocol="https" bindingInformation="*:44310:localhost" />
</bindings>
Since this is our dev box, and we would like to make things easy on ourselves, I'm just going to change bindings to allow all.
<bindings>
<binding protocol="http" bindingInformation=":53391:" />
<binding protocol="https" bindingInformation=":44310:" />
</bindings>
4οΈβ£ It Works!!! πππ
Save, Re-launch your API and refresh the browser on your emulator!.
Top comments (0)