Windows Phone 8 Emulator: Access localhost

2020-02-09 08:28发布

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?

5条回答
劫难
2楼-- · 2020-02-09 08:28

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.

查看更多
够拽才男人
3楼-- · 2020-02-09 08:28

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

查看更多
\"骚年 ilove
4楼-- · 2020-02-09 08:39

I had this is problem when I was running my cordova app with windows phone 8 emulator. In my case I was running my app in release mode. When I change the mode to debug I was able to access local web server from my app.

http://guntucomputerhacks.blogspot.com.au/

查看更多
女痞
5楼-- · 2020-02-09 08:46

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.

查看更多
一纸荒年 Trace。
6楼-- · 2020-02-09 08:55

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.

查看更多
登录 后发表回答