14

I created MVC4 Mobile Application using VS 2012 default template. It's working fine in desktop browser using http://localhost/mvcapplication1/ but when I tried running the same app in WP8 Emulator browser it's not working and showing message "We're having trouble displaying this page". I also tried with IP address (127.0.0.1) but still no luck. Please tell me how can I connect to localhost using WP8 Emulator browser?

Claus Jørgensen
  • 25,882
  • 9
  • 87
  • 150
brijshah
  • 175
  • 1
  • 1
  • 6
  • 1
    Try the host machine's IP address. – SLaks Oct 30 '12 at 23:56
  • It's giving access denied message. – brijshah Oct 31 '12 at 00:05
  • @Brijen you might give [this](http://stackoverflow.com/a/13185379/69742) a look over. (make sure you can connect to the internet in the first place). Another thing to make sure if is that the port is not being blocked by your firewall. But yes, the other answers are correct. You must use the internal IP, not `localhost` – Earlz Nov 02 '12 at 14:28

4 Answers4

24

The Windows Phone 8 emulator is actually a full virtual machine with its own internal IP address.
Therefore, localhost means the (virtual) phone, not your PC.

To connect to the host PC, you need to enter its internal IP address.

You also need to configure IIS Express and your firewall to accept connections from other computers.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • I can access the same URL from other computer desktop browser so assuming firewall is setup correctly. Do you know any specific settings for WP8 Emulator. Also, I am not using IIS Express but still configured IIS Express using `netsh http add urlacl url=http://<>:8080/ user=everyone` Still not able to browse from WP8 – brijshah Oct 31 '12 at 00:45
  • Is your desktop joined to a corporate domain? The Emulator will be a non-domain joined machine, you will need to add a IPSec boundary exception for desktop machine for Emulator to access it. – Arun M Nov 02 '12 at 04:49
  • I was able to get it to work by stripping "localhost" from the IIS Express config and allowing the port using firewall. But now I have hard coded the dev machine's ip address. How does this work with source code control and multiple developers? – tofutim Nov 22 '12 at 06:31
  • your answer solved my problem after 4 days of troubleshooting, research, and fiddling. thank you very, very much. – Mina Apr 15 '13 at 12:48
  • Just to be clear, i had to use the IP of the Windows phone Emulator VM is using, not the PC's – Layinka Feb 14 '14 at 09:38
8

I was looking for an answer for this too and found out there is now an official answer from Microsoft at:

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj684580%28v=vs.105%29.aspx

jumantyn
  • 91
  • 7
1

You can install fiddler and go through the instruction on how to configure fiddler for windows emulator.

This article worked just fine for me: http://blogs.msdn.com/b/wsdevsol/archive/2013/06/05/configure-the-windows-phone-8-emulator-to-work-with-fiddler.aspx

One the configuration is done, emulator will automatically use fiddler as a proxy server and you localhost should work just fine from emulator too.

Remember to start fiddler before starting the emulator to route the traffic, otherwise it wont work. You will also be able to monitor http/https requests made by windows emulator.

xySVerma
  • 941
  • 9
  • 12
0

Try to use your IP instead of using (localhost)

1- from start menu open command prompt 2- write ipconfig 3- you will find your ip address beside ipv4 adress if it doesn't work try those additional steps from MSDN

To create a firewall exception for HTTP requests to IIS Express From the Windows Start screen, search for Windows Firewall. Click to run the program. On the Windows Firewall screen, click Advanced settings. On the Windows Firewall with Advanced Security screen, select Inbound Rules. Then click New Rule. On the Rule Type page of the New Inbound Rule Wizard, select Port. Then click Next. On the Protocols and Ports page, enter the port number that IIS Express is using in the Specific local ports field. Then click Next.

On the Action page, select Allow the connection. Then click Next. On the Profile page, select Private and, if applicable, Domain. Do not select Public. Then click Next. On the Name page, type a name for the rule – for example, Local web service for testing. Then click Finish.