This is probably one of the most frequently asked questions on WinRT in the forums. The answer is – no, you cannot communicate with localhost. You can communicate with a service running on the local network, the intranet, or the internet. But you cannot connect to the loop back address. This is by design. It’s a security measure, and also a side-effect of how a Metro app cannot take any assumptions about the machine it’s running on. And expecting a localhost service to be running is such an assumption. So what’s the alternative? Use the cloud
Note: you can connect to localhost for debugging, but your app will not be approved for publishing to the store.
Can you connect to a service running on the same machine using it’s local network address (192.168.0.X) for example instead of 127.0.0.1, or is that prohibited too?
That won’t work either. Eventually, all of those will resolve to 127.0.0.1 and will be blocked.
It’s not so much a technical limitation as it is a certification constraint. Actually, when you’re developing your app, you’ll notice that you _can_ access localhost (or 127.0.0.1 or 192.168.0.x). But when you try to get your app certified for the Windows Store, they’re going to check that you aren’t implementing an architecture that relies on local services. If you create an enterprise app that you don’t need to publish to the Store for distribution and monetization, you are free to connect to the localhost.
How is this possible? Can you explain Foster please with simple sample?
thanks